Make Instruction Emulation Code More Tolerant of Bad Addresses

Robert Shearman rob at codeweavers.com
Sat Jun 18 22:41:59 CDT 2005


Hi,

Below are the outputs from a sample program that does a call to an 
invalid address. The first trace is without the patch and the second is 
with.

=>1 0x7fe3704c INSTR_EmulateInstruction+0xb8(rec=0x7fbbfe2c, 
context=0x7fbbfb60) [/home/rob/wine/dlls/kernel/instr.c:455] in kernel32 
(0x7fbbfa90)
  2 0x7fe700f3 vectored_handler(ptrs=0x7fbbfacc) 
[/home/rob/wine/dlls/kernel/wowthunk.c:357] in kernel32 (0x7fbbfaac)
  3 0xb7e39082 __regs_RtlRaiseException+0xc2(rec=0x7fbbfe2c, 
context=0x7fbbfb60) [/home/rob/wine/dlls/ntdll/exception.c:196] in ntdll 
(0x7fbbfb30)
  4 0xb7e54b7f raise_segv_exception(rec=0x7fbbfe2c, context=0x7fbbfb60) 
[/home/rob/wine/dlls/ntdll/signal_i386.c:887] in ntdll (0x7fbbfb4c)
  5 0xb7e5d4d4 __wine_call_from_32_restore_regs in ntdll (0x7fbbfe9c)
  6 0x7fbde163 __wine_exe_main in winver (0x7fbbff2c)
  7 0x7fe504ff start_process(arg=0x0) 
[/home/rob/wine/dlls/kernel/process.c:1044] in kernel32 (0x7fbbfff4)
  8 0xb7fc0535 wine_switch_to_stack+0x11 in libwine.so.1 (0x00000000)
0x7fe3704c INSTR_EmulateInstruction+0xb8 
[/home/rob/wine/dlls/kernel/instr.c:455] in kernel32: movb     0x0(%edi),%dl
455             switch(*instr)

Backtrace:
=>1 0x0000cccc (0x7fbbfe9c)
  2 0x7fbde163 __wine_exe_main+0x163 in winver (0x7fbbff2c)
  3 0x7fe504ff start_process+0xc3(arg=0x0) 
[/home/rob/wine/dlls/kernel/process.c:1044] in kernel32 (0x7fbbfff4)
  4 0xb7fc0535 wine_switch_to_stack+0x11 in libwine.so.1 (0x00000000)
0x0000cccc: addb        %al,0x0(%eax)

Therefore this patch aids in debugging. It isn't perfect because of 
x86's variable length instructions, but it is fairly unlikely that an 
instruction will straddle a page boundary and the first page be readable 
and the second not.

Changelog:
Make instruction emulation code more tolerant of bad addresses by 
checking the instruction pointer refers to readable memory.

-- 
Rob Shearman

-------------- next part --------------
A non-text attachment was scrubbed...
Name: instr.diff
Type: text/x-patch
Size: 677 bytes
Desc: not available
Url : http://www.winehq.org/pipermail/wine-patches/attachments/20050618/431606a3/instr.bin


More information about the wine-patches mailing list