Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CRASH x64 drinject stack mis-alignment: instr_create_restore_from_dc_via_reg() #13

Closed
derekbruening opened this issue Nov 27, 2014 · 1 comment

Comments

@derekbruening
Copy link
Contributor

From [email protected] on February 15, 2009 15:49:30

Just running release build x64 drinject on
suite/tests/client-interface/strace I hit a somewhat non-deterministic
crash: only happens within test harness. The problem is that drinject is
not aligning the stack to 16 for the 3 calls it makes. The crash shows up
like this:

(adc.158): Access violation - code c0000005 (first chance)
First chance exceptions are reported before any exception handling.
This exception may be expected and handled.
dynamorio!instr_create_restore_from_dc_via_reg+0x10c:
000000007107fb2c 0f28442420 movaps xmm0,xmmword ptr [rsp+20h] ss:000000000012fa68=0000000800000128000000001f009006
0:000> kn

Child-SP RetAddr Call Site

00 000000000012fa48 0000000071066448
dynamorio!instr_create_restore_from_dc_via_reg+0x10c
[d:\derek\opensource\dynamorio\core\x86\instr.c @ 4818]
01 000000000012fa98 0000000071068ab4
dynamorio!emit_fcache_enter_common+0x128
[d:\derek\opensource\dynamorio\core\x86\emit_utils.c @ 3173]
02 000000000012fc78 000000007105b103
dynamorio!emit_fcache_enter_shared+0x14
[d:\derek\opensource\dynamorio\core\x86\emit_utils.c @ 3825]
03 000000000012fcb8 000000007105b7c0 dynamorio!shared_gencode_init+0x113
[d:\derek\opensource\dynamorio\core\x86\arch.c @ 308]
04 000000000012fd48 000000007102470b dynamorio!arch_init+0x10
[d:\derek\opensource\dynamorio\core\x86\arch.c @ 523]
05 000000000012fd78 0000000071090562 dynamorio!dynamorio_app_init+0x10b
[d:\derek\opensource\dynamorio\core\dynamo.c @ 463]
06 000000000012fde8 0000000071093a00 dynamorio!auto_setup+0x22
[d:\derek\opensource\dynamorio\core\x86\x86_code.c @ 144]
07 000000000012fe28 0000000000000000 dynamorio!dynamo_auto_start+0x10
0:000> r
rax=0000000000000000 rbx=000000001f602270 rcx=ffffffffffffffff
rdx=0000000000000068 rsi=ffffffffffffffff rdi=ffffffffffffffff
rip=000000007107fb2c rsp=000000000012fa48 rbp=0000000000000000 r8 =000000001f5d2111 r9 =0000000000000128 r10 =0000000000000000 r11 =000000000012fbb8 r12 =0000000000000000 r13 =0000000000000000 r14 =000000001f601570 r15 =000000001f602280
iopl=0 nv up ei pl zr na po nc
cs=0033 ss=002b ds=002b es=002b fs=0053 gs=002b efl=00010246
dynamorio!instr_create_restore_from_dc_via_reg+0x10c:
000000007107fb2c 0f28442420 movaps xmm0,xmmword ptr [rsp+20h] ss:000000000012fa68=0000000800000128000000001f009006

Original issue: http://code.google.com/p/dynamorio/issues/detail?id=13

@derekbruening
Copy link
Contributor Author

From [email protected] on February 17, 2009 09:54:51

fixed in r28

Status: Verified

derekbruening added a commit that referenced this issue Jul 5, 2023
8 of the 13 tests on Mac AArch64 labeled "OSX" fail prior to this PR.
Here we fix the following:

+ Syscall success is indicated by the carry flag just like x86 Mac
+ Handle sigreturn with its extra parameters just like x86 Mac
+ Fix signal handler parameters
+ Fix stolen register support in signal contexts
+ Use MAP_JIT and pthread_jit_write_protect_np for +rwx gencode in tests
+ Use DYLD_LIBRARY_PATH on Mac in tests

Now all 13 tests pass:
---------------------------------------------------------------------------------------
ctest -j 5 -L OSX
 1/13 Test  #13: code_api|common.fib ................................  Passed  0.59 sec
 2/13 Test #243: code_api|libutil.frontend_test .....................  Passed  0.63 sec
 3/13 Test #231: code_api|api.ir ....................................  Passed  0.67 sec
 4/13 Test   #9: code_api|linux.sigaction.native ....................  Passed  0.25 sec
 5/13 Test  #31: code_api|linux.signal0000 ..........................  Passed  0.10 sec
 6/13 Test #240: code_api|api.ir-static .............................  Passed  0.34 sec
 7/13 Test #241: code_api|api.drdecode ..............................  Passed  0.38 sec
 8/13 Test #245: code_api|api.dis-a64 ...............................  Passed  1.15 sec
 9/13 Test #264: no_code_api,no_intercept_all_signals|linux.sigaction  Passed  0.08 sec
10/13 Test  #33: code_api|linux.signal0010 ..........................  Passed  0.34 sec
11/13 Test  #35: code_api|linux.signal0100 ..........................  Passed  0.42 sec
12/13 Test  #37: code_api|linux.signal0110 ..........................  Passed  0.45 sec
13/13 Test   #7: samples_proj .......................................  Passed  1.89 sec
100% tests passed, 0 tests failed out of 13
---------------------------------------------------------------------------------------

Issue: #5383
github-merge-queue bot pushed a commit that referenced this issue Jul 7, 2023
8 of the 13 tests on Mac AArch64 labeled "OSX" fail prior to this PR.
Here we fix the following:

+ Syscall success is indicated by the carry flag just like x86 Mac
+ Handle sigreturn with its extra parameters just like x86 Mac
+ Fix signal handler parameters
+ Fix stolen register support in signal contexts
+ Use MAP_JIT and pthread_jit_write_protect_np for +rwx gencode in tests
+ Use DYLD_LIBRARY_PATH on Mac in tests

Now all 13 tests pass:
```
---------------------------------------------------------------------------------------
$ ctest -j 5 -L OSX
 1/13 Test  #13: code_api|common.fib ................................  Passed  0.59 sec
 2/13 Test #243: code_api|libutil.frontend_test .....................  Passed  0.63 sec
 3/13 Test #231: code_api|api.ir ....................................  Passed  0.67 sec
 4/13 Test   #9: code_api|linux.sigaction.native ....................  Passed  0.25 sec
 5/13 Test  #31: code_api|linux.signal0000 ..........................  Passed  0.10 sec
 6/13 Test #240: code_api|api.ir-static .............................  Passed  0.34 sec
 7/13 Test #241: code_api|api.drdecode ..............................  Passed  0.38 sec
 8/13 Test #245: code_api|api.dis-a64 ...............................  Passed  1.15 sec
 9/13 Test #264: no_code_api,no_intercept_all_signals|linux.sigaction  Passed  0.08 sec
10/13 Test  #33: code_api|linux.signal0010 ..........................  Passed  0.34 sec
11/13 Test  #35: code_api|linux.signal0100 ..........................  Passed  0.42 sec
12/13 Test  #37: code_api|linux.signal0110 ..........................  Passed  0.45 sec
13/13 Test   #7: samples_proj .......................................  Passed  1.89 sec
100% tests passed, 0 tests failed out of 13
---------------------------------------------------------------------------------------
```
Issue: #5383
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant