DynamoRIO / DynamoRIO/dynamorio
ASSERT utils.h:1345(try__except) == &global_try_except || (try__except) == NULL || (try__except) == &get_thread_private_dcontext()->try_except
- Dominant language
- C
- Stars
- 3.2k
- Forks
- 629
- Avg merge
- 2d 15h
- Merged PRs (30d)
- 31
Description
On a 64-bit Ubuntu 18.04 system, with DynamoRIO 7.0.0-RC1, and a 64-bit application, I'm encountering the following assertion failure, while instrumenting a [benchmark program](https://github.com/kozyraki/stamp) for a [transactional memory framework](https://github.com/patrickmarlier/tinySTM).
```
../DynamoRIO-Linux-7.0.0-RC1/bin64/drrun -debug -c ../tinySTM/instrumentation/build/libstm-dynamorio.so -- ./intruder/intruder -a10 -l4 -n2048 -s1 -t4
<(1+x) Handling our fault in a TRY at 0x00007ffff7e7ce66>
Percent attack = 10
Max data length = 4
Num flow = 2048
Random seed = 1
Num attack = 174
Thread 2 "intruder" hit Breakpoint 1, report_dynamorio_problem (dcontext=0x0, dumpcore_flag=8, exception_addr=0x0, report_ebp=0x0, fmt=0x7ffff7f0a258 "DynamoRIO debug check failure: %s:%d %s\n(Error occurred @%d frags)") at /dynamorio_package/core/utils.c:2171
(gdb)
try_except
(Error occurred @5283 frags)
version 7.0.0, build 1
-no_dynamic_options -client_lib '/mnt/data/sources/stamp/../tinySTM/instrumentation/build/libstm-dynamorio.so;0;' -code_api -stack_size 56K -max_elide_jmp 0 -max_elide_call 0 -early_inject -emulate_brk -no_inline_ignored_syscalls -native_exec_default_list '' -no_native_exec_managed_code -no_indcall2direct
0x00007fff7762d340 0x00007ffff7cd8988
0x00007fff7762d590 0x00007ffff7deb3d4
0x00007fff7762d730 0x00007ffff7e49489
0x00007fff7762d990 0x00007ffff7e51912
0x00007fff7762dab0 0x00007ffff7e521bf
0x00007fff7762dcb0 0x00007ffff7de7fad
0x00007fff7762e2f0 0x00007ffff7de95e8
0x00007fff7762e330 0x00007ffff7dc42f9
0x00007fff7762e380 0x00007ffff7dc572b
0x00007fff7762e6a0 0x00007ffff7dc6dbd
0x00007fff7762e760 0x00007ffff7c74b38
0x00007fff7762e820 0x00007ffff7c76c86
0x00007fff7762e870 0x00007ffff7c77d7a
0x00007fff7762e8f0 0x00007ffff7c7850c
0x00007fff7762e940 0x00007ffff7de257c
/mnt/data/sources/stamp/../tinySTM/instrumentation/build/libstm-dynamorio.so=0x00007fff771b6000
/mnt/data/sources/DynamoRIO-Linux-7.0.0-RC1/ext/lib64/debug/libdrwrap.so=0x00007fff7f3c0000
/mnt/data/sources/DynamoRIO-Linux-7.0.0-RC1/ext/lib64/debug/libdrmgr.so=0x00007fff7f3ce000>
[LWP 76995 exited]
[LWP 76994 exited]
[LWP 76990 exited]
[Inferior 1 (process 76990) exited with code 0377]
```
Inspecting the crash under GDB shows that the `try__except` variable is pointing at another thread's handler. This resembles #2627.
```
(gdb) i threads
Id Target Id Frame
1 LWP 76990 "intruder" syscall_ready () at /dynamorio_package/core/arch/x86/x86_shared.asm:180
* 2 LWP 76994 "intruder" 0x00007ffff7dd028d in parse_int (sp=0x7ffff7ff7e6c "00000000 00:00 0 ",
res_out=0x7fff7762ce40, base=16, width=16, is_signed=false) at /dynamorio_package/core/io.c:456
3 LWP 76995 "intruder" syscall_ready () at /dynamorio_package/core/arch/x86/x86_shared.asm:180
4 LWP 76996 "intruder" syscall_ready () at /dynamorio_package/core/arch/x86/x86_shared.asm:180
(gdb) bt
#0 0x00007ffff7dd028d in parse_int (sp=0x7ffff7ff7e6c "00000000 00:00 0 ", res_out=0x7fff7762ce40, base=16,
width=16, is_signed=false) at /dynamorio_package/core/io.c:456
#1 0x00007ffff7dd08c7 in our_vsscanf (str=0x7ffff7ff7e4d "7fff773c3000-7fff773c5000 ---p 00000000 00:00 0 ",
fmt=0x7ffff7f64040 "%016lx-%016lx %s %016lx %*s %lu %4096s", ap=0x7fff7762cec0) at /dynamorio_package/core/io.c:658
#2 0x00007ffff7dd0cc5 in our_sscanf (str=0x7ffff7ff7e4d "7fff773c3000-7fff773c5000 ---p 00000000 00:00 0 ",
fmt=0x7ffff7f64040 "%016lx-%016lx %s %016lx %*s %lu %4096s") at /dynamorio_package/core/io.c:717
#3 0x00007ffff7ec9240 in memquery_iterator_next (iter=0x7fff7762d040) at /dynamorio_package/core/unix/memquery_linux.c:238
#4 0x00007ffff7ec96a4 in memquery_from_os (pc=0x7fff7762e000 "\250\067}w\377\177", info=0x7fff7762d160, have_type=0x7fff7762d12e)
at /dynamorio_package/core/unix/memquery_linux.c:329
#5 0x00007ffff7eaa890 in query_memory_ex_from_os (pc=0x7fff7762e000 "\250\067}w\377\177", info=0x7fff7762d160)
at /dynamorio_package/core/unix/os.c:9186
#6 0x00007ffff7eaa943 in get_memory_info_from_os (pc=0x7fff7762e000 "\250\067}w\377\177", base_pc=0x0, size=0x0,
prot=0x7fff7762d1b0) at /dynamorio_package/core/unix/os.c:9219
#7 0x00007ffff7e9d412 in is_readable_without_exception_internal (pc=0x7fff7762e2f0 "0\343bw\377\177", size=16, query_os=true)
at /dynamorio_package/core/unix/os.c:4600
#8 0x00007ffff7e9d514 in is_readable_without_exception_query_os (pc=0x7fff7762e2f0 "0\343bw\377\177", size=16)
at /dynamorio_package/core/unix/os.c:4627
#9 0x00007ffff7cdde81 in report_dynamorio_problem (dcontext=0x7fff77494140, dumpcore_flag=8, exception_addr=0x0,
report_ebp=0x7fff7762d340 "\220\325bw\377\177",
fmt=0x7ffff7f0a258 "DynamoRIO debug check failure: %s:%d %s\n(Error occurred @%d frags)")
at /dynamorio_package/core/utils.c:2223
#10 0x00007ffff7cd8988 in internal_error (file=0x7ffff7f37a88 "/dynamorio_package/core/annotations.c", line=361,
expr=0x7ffff7f37ab0 "(try__except) == &global_try_except || (try__except) == NULL || (try__except) == &get_thread_private_dconte
xt()->try_except") at /dynamorio_package/core/utils.c:175
#11 0x00007ffff7deb3d4 in instrument_annotation (dcontext=0x7fff77499340, start_pc=0x7fff7762da58, substitution=0x7fff7762d760)
at /dynamorio_package/core/annotations.c:355
#12 0x00007ffff7e49489 in build_bb_ilist (dcontext=0x7fff77499340, bb=0x7fff7762d9e0) at /dynamorio_package/core/arch/interp.c:3632
#13 0x00007ffff7e51912 in recreate_bb_ilist (dcontext=0x7fff77499340, pc=0x7ffff719a248 "\353\021H\213\004%ڻ!",
pretend_pc=0x7ffff719a248 "\353\021H\213\004%ڻ!", stop_pc=0x0, flags=0, res_flags=0x7fff7762dc3c,
res_exit_type=0x7fff7762dbec, check_vm_area=true, mangle=false, vmlist_out=0x7fff7762db20, call_client=true, for_trace=true)
at /dynamorio_package/core/arch/interp.c:5244
#14 0x00007ffff7e521bf in recreate_fragment_ilist (dcontext=0x7fff77499340, pc=0x0, f_res=0x7fff7762e288,
alloc_res=0x7fff7762e27f, mangle=true, call_client=true) at /dynamorio_package/core/arch/interp.c:5375
#15 0x00007ffff7de7fad in recreate_app_state_internal (tdcontext=0x7fff77499340, mcontext=0x7fff7762e3b0, just_pc=false,
owning_f=0x0, restore_memory=false) at /dynamorio_package/core/translate.c:1063
#16 0x00007ffff7de95e8 in recreate_app_state (tdcontext=0x7fff77499340, mcontext=0x7fff7762e3b0, restore_memory=false, f=0x0)
at /dynamorio_package/core/translate.c:1303
#17 0x00007ffff7dc42f9 in at_safe_spot (trec=0x7fff77499840, mc=0x7fff7762e3b0,
desired_state=THREAD_SYNCH_SUSPENDED_VALID_MCONTEXT_OR_NO_XFER) at /dynamorio_package/core/synch.c:543
#18 0x00007ffff7dc572b in synch_with_thread (id=76996, block=false, hold_initexit_lock=true, caller_state=THREAD_SYNCH_NONE,
desired_state=THREAD_SYNCH_SUSPENDED_VALID_MCONTEXT_OR_NO_XFER, flags=2) at /dynamorio_package/core/synch.c:950
#19 0x00007ffff7dc6dbd in synch_with_all_threads (desired_synch_state=THREAD_SYNCH_SUSPENDED_VALID_MCONTEXT_OR_NO_XFER,
threads_out=0x7ffff7fb1000 , num_threads_out=0x7ffff7fb1008 ,
cur_state=THREAD_SYNCH_NO_LOCKS_NO_XFER, flags=2) at /dynamorio_package/core/synch.c:1327
#20 0x00007ffff7c74b38 in flush_fragments_synchall_start (ignored=0x7fff77494140,
base=0x7ffff71928e1 "H\211\205P\377\377\377\351%\001", size=1, exec_invalid=false) at /dynamorio_package/core/fragment.c:6018
#21 0x00007ffff7c76c86 in flush_fragments_synch_unlink_priv (dcontext=0x7fff77494140,
base=0x7ffff71928e1 "H\211\205P\377\377\377\351%\001", size=1, own_initexit_lock=false, exec_invalid=false,
force_synchall=true) at /dynamorio_package/core/fragment.c:6546
#22 0x00007ffff7c77d7a in flush_fragments_in_region_start (dcontext=0x7fff77494140,
base=0x7ffff71928e1 "H\211\205P\377\377\377\351%\001", size=1, own_initexit_lock=false, free_futures=false,
exec_invalid=false, force_synchall=true) at /dynamorio_package/core/fragment.c:6843
#23 0x00007ffff7c7850c in flush_fragments_from_region (dcontext=0x7fff77494140,
base=0x7ffff71928e1 "H\211\205P\377\377\377\351%\001", size=1, force_synchall=true) at /dynamorio_package/core/fragment.c:6918
#24 0x00007ffff7de257c in dr_flush_region (start=0x7ffff71928e1 "H\211\205P\377\377\377\351%\001", size=1)
at /dynamorio_package/core/lib/instrument.c:6703
#25 0x00007fff7f3c5bdb in drwrap_mark_retaddr_for_instru (drcontext=0x7fff77494140,
decorated_pc=0x7ffff719a370 "\351;\375\377\377\220f.\017\037\204", wrapcxt=0x7fff7762ea20, enabled=1 '\001')
at /dynamorio_package/ext/drwrap/drwrap.c:1690
#26 0x00007fff7f3c5e02 in drwrap_ensure_postcall (drcontext=0x7fff77494140, wrap=0x7fff773df2e8, wrapcxt=0x7fff7762ea20,
decorated_pc=0x7ffff719a370 "\351;\375\377\377\220f.\017\037\204") at /dynamorio_package/ext/drwrap/drwrap.c:1764
#27 0x00007fff7f3c60fa in drwrap_in_callee (arg1=0x7ffff719a370, xsp=140737326889208)
at /dynamorio_package/ext/drwrap/drwrap.c:1833
#28 0x00007fff777c7531 in ?? ()
#29 0x00007fffe0000900 in ?? ()
#30 0x00007ffff66f4ba0 in ?? ()
#31 0x00007ffff66039f0 in ?? ()
#32 0x00007ffff66038f8 in ?? ()
#33 0x00007fffe0000e88 in ?? ()
#34 0x00007ffff66f4b80 in ?? ()
#35 0x0000000000000009 in ?? ()
#36 0x00007fffe0000900 in ?? ()
#37 0x00007fffe0000900 in ?? ()
#38 0x0000000000000000 in ?? ()
(gdb) p try__except
$27 = (try_except_t *) 0x7fff774997e8
(gdb) p *try__except
$28 = {try_except_state = 0x0, unwinding_exception = false}
(gdb) p/x try__state
$30 = {context = {xbx = 0x7ffff719a248, xcx = 0x7fff77499340, xdi = 0x57762d5f0, xsi = 0x12cc2, xbp = 0x7fff7762d610,
xsp = 0x7ffff7e9896c, xip = 0x7fff7762d610, r8 = 0x7fff77494140, r9 = 0x7fff777f5b60, r10 = 0x60, r11 = 0x60,
r12 = 0x277491668, r13 = 0x7fff77499340, r14 = 0x7fff77494140, r15 = 0x7fff77494140, sigmask = {sig = {0x7ffff7f9e320}}},
prev_context = 0x12cc2}
(gdb) t 1
[Switching to thread 1 (LWP 76990)]
#0 syscall_ready () at /dynamorio_package/core/arch/x86/x86_shared.asm:180
(gdb) p &get_thread_private_dcontext()->try_except
$31 = (try_except_t *) 0x7fff77445528
(gdb) t 2
[Switching to thread 2 (LWP 76994)]
#0 parse_int(sp=0x7ffff7ff7e6c, res_out=0x7fff7762ce40, base=16, width=16, is_signed=false) at /dynamorio_package/core/io.c:456
(gdb) p &get_thread_private_dcontext()->try_except
$31 = (try_except_t *) 0x7fff774945e8
(gdb) t 3
[Switching to thread 3 (LWP 76995)]
#0 syscall_ready () at /dynamorio_package/core/arch/x86/x86_shared.asm:180
(gdb) p &get_thread_private_dcontext()->try_except
$31 = (try_except_t *) 0x7fff774976a8
(gdb) t 4
[Switching to thread 4 (LWP 76996)]
#0 syscall_ready () at /dynamorio_package/core/arch/x86/x86_shared.asm:180
(gdb) p &get_thread_private_dcontext()->try_except
$31 = (try_except_t *) 0x7fff774997e8
```
Contributor guide
Assessment
This issue has not been assessed yet.