You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
% bin32/drrun -t drmemory_light -- calc
~~Dr.M~~ Dr. Memory version 1.8.0
~~Dr.M~~ Running "calc"
~~Dr.M~~ WARNING: application exited with abnormal code 0xc0000409
I tried 5.0.0 -- crashes too.
In my notes, I tested win8.1 64 and 32 kernels: certainly it used to work,
so this must be due to a recent Windows Update?
Indeed, Qin's win8.1 x64 VM works fine, and his ntdll doesn't have the new
call in DR i#1599.
My theory: I think that there is a new Windows kernel security feature
where on any fault if the stack pointer doesn't match what the app's stack
should be, it throws an uncatchable 0xc0000409. So on the first
is_retaddr fault, kernel kills us.
To solve we'd have to write into TEB stack fields on cxt sw I guess and
hope kernel reads those and hasn't cached sthg. Or have only dr_try and
safe_read do that?
The text was updated successfully, but these errors were encountered:
Indeed, if on 1st chance AV in windbg I write to the 2 TEB fields, we
continue w/o the 0xc0000409.
It also works if I write to just StackBase such that esp is inside there:
esp=1f17eba8
StackBase: 00950000
StackLimit: 00948000
=>
StackBase: 1f17f000
StackLimit: 00948000
dr_call_on_clean_stack() is static so we have to pay the cost on all
Windows versions, unless we want dr_call_on_clean_stack_win81 or sthg and
dispatch.
Is the cost measurable:
06:56 PM ~/extsw/heaplayers-351/benchmarks/cfrac
% for ((i=0; i<3; i++)); do /usr/bin/time ~/drmemory/git/build_x86_rel/bin/drmemory.exe -light -dr d:/derek/dr/git/exports -batch -- ./cfrac.exe 41757646344123832613190542166099121; done
dr_call_on_clean_stack w/o swaps:
0.00user 0.01system 0:30.12elapsed 0%CPU (0avgtext+0avgdata 262144maxresident)k
0.01user 0.00system 0:28.43elapsed 0%CPU (0avgtext+0avgdata 262400maxresident)k
0.00user 0.00system 0:30.38elapsed 0%CPU (0avgtext+0avgdata 262400maxresident)k
dr_call_on_clean_stack w/ swaps:
0.01user 0.00system 0:31.93elapsed 0%CPU (0avgtext+0avgdata 262144maxresident)k
0.00user 0.01system 0:27.61elapsed 0%CPU (0avgtext+0avgdata 262400maxresident)k
0.01user 0.00system 0:27.91elapsed 0%CPU (0avgtext+0avgdata 262144maxresident)k
So maybe not a big deal.
derekbruening
changed the title
drmemory crashes on calc on recently-updated win8.1
drmemory crashes on calc on recently-updated win8.1 due to kernel checking TEB stack fields
Feb 4, 2015
An alternative for dr_call_on_clean_stack() is to change DR_STATE_TO_SWAP in DrMem to include
DR_STATE_STACK_BOUNDS. The call to dr_switch_to_dr_state_ex() is prior to
the stack swap though, and it seems best to ensure we can handle faults anywhere.
I tried 5.0.0 -- crashes too.
In my notes, I tested win8.1 64 and 32 kernels: certainly it used to work,
so this must be due to a recent Windows Update?
Indeed, Qin's win8.1 x64 VM works fine, and his ntdll doesn't have the new
call in DR i#1599.
define STATUS_STACK_BUFFER_OVERRUN ((NTSTATUS)0xC0000409L) // winnt
(8dc.3f8): Access violation - code c0000005 (first chance)
First chance exceptions are reported before any exception handling.
This exception may be expected and handled.
eax=00000000 ebx=0003100c ecx=21eb1258 edx=00c30000 esi=21e2ef58 edi=00000001
eip=739d0001 esp=21e2e314 ebp=21e2e434 iopl=0 nv up ei pl zr na pe nc
cs=0023 ss=002b ds=002b es=002b fs=0053 gs=002b efl=00010246
739d0001 0fb642fb movzx eax,byte ptr [edx-5] ds:002b:00c2fffb=??
0:000> g
(8dc.3f8): Security check failure or stack buffer overrun - code c0000409 (!!! second chance !!!)
eax=00000000 ebx=0003100c ecx=21eb1258 edx=00c30000 esi=21e2ef58 edi=00000001
eip=739d0001 esp=21e2e314 ebp=21e2e434 iopl=0 nv up ei pl zr na pe nc
cs=0023 ss=002b ds=002b es=002b fs=0053 gs=002b efl=00010246
739d0001 0fb642fb movzx eax,byte ptr [edx-5] ds:002b:00c2fffb=??
Or if I have windbg ignore access violation:
(9c8.3ec): Access violation - code c0000005 (first chance)
(9c8.3ec): Security check failure or stack buffer overrun - code c0000409 (!!! second chance !!!)
eax=00000000 ebx=0003100c ecx=245f1258 edx=00c30000 esi=2456ef58 edi=00000001
eip=739d0001 esp=2456e314 ebp=2456e434 iopl=0 nv up ei pl zr na pe nc
cs=0023 ss=002b ds=002b es=002b fs=0053 gs=002b efl=00010246
739d0001 0fb642fb movzx eax,byte ptr [edx-5] ds:002b:00c2fffb=??
My theory: I think that there is a new Windows kernel security feature
where on any fault if the stack pointer doesn't match what the app's stack
should be, it throws an uncatchable 0xc0000409. So on the first
is_retaddr fault, kernel kills us.
To solve we'd have to write into TEB stack fields on cxt sw I guess and
hope kernel reads those and hasn't cached sthg. Or have only dr_try and
safe_read do that?
The text was updated successfully, but these errors were encountered: