client.thread failing on win8.1
Split from #2145 (closed) as it has several parts perhaps worth documenting:
client.thread DR assert
<Attached to 2 threads in application C:\derek\appveyor\client.thread.exe (4360)>
<Application C:\derek\appveyor\client.thread.exe (4360). Internal Error: DynamoRIO debug check failure: C:\derek\dr\git\src\core\win32\loader.c:514 !is_dynamo_address(dcontext->app_stack_limit) || IS_CLIENT_THREAD(dcontext)
04 1f2aec78 61431633 dynamorio!internal_error+0x133 [c:\derek\dr\git\src\core\utils.c @ 190]
05 1f2aece0 6143121c dynamorio!is_using_app_peb+0x223 [c:\derek\dr\git\src\core\win32\loader.c @ 514]
06 1f2aecec 6143a834 dynamorio!os_using_app_state+0xc [c:\derek\dr\git\src\core\win32\loader.c @ 807]
07 1f2aed04 614398fc dynamorio!redirect_heap_call+0x44 [c:\derek\dr\git\src\core\win32\drwinapi\ntdll_redir.c @ 263]
08 1f2aed10 6143bb14 dynamorio!redirect_RtlValidateHeap+0xc [c:\derek\dr\git\src\core\win32\drwinapi\ntdll_redir.c @ 430]
09 1f2aed24 61cd51ae dynamorio!redirect_HeapValidate+0x14 [c:\derek\dr\git\src\core\win32\drwinapi\kernel32_mem.c @ 214]
0a 1f2aed38 61cd67ed client_thread_dll!_CrtIsValidHeapPointer+0x3e [f:\dd\vctools\crt\crtw32\misc\dbgheap.c @ 2034]
0b 1f2aed48 61cd669e client_thread_dll!_free_dbg_nolock+0x11d [f:\dd\vctools\crt\crtw32\misc\dbgheap.c @ 1322]
0c 1f2aed80 61cd2758 client_thread_dll!_free_dbg+0x4e [f:\dd\vctools\crt\crtw32\misc\dbgheap.c @ 1265]
0d 1f2aedc4 61cd27ad client_thread_dll!_freefls+0x1e8 [f:\dd\vctools\crt\crtw32\startup\tidtable.c @ 433]
0e 1f2aedd0 61cd2068 client_thread_dll!_freeptd+0x3d [f:\dd\vctools\crt\crtw32\startup\tidtable.c @ 484]
0f 1f2aee08 61cd21eb client_thread_dll!_CRT_INIT+0x228 [f:\dd\vctools\crt\crtw32\startup\dllcrt0.c @ 256]
10 1f2aee54 61cd20af client_thread_dll!__DllMainCRTStartup+0x12b [f:\dd\vctools\crt\crtw32\startup\dllcrt0.c @ 399]
11 1f2aee68 61432680 client_thread_dll!_DllMainCRTStartup+0x1f [f:\dd\vctools\crt\crtw32\startup\dllcrt0.c @ 340]
12 1f2aeed4 612f2633 dynamorio!privload_call_entry+0x220 [c:\derek\dr\git\src\core\win32\loader.c @ 1321]
13 1f2aeee8 61163cfa dynamorio!loader_thread_exit+0x63 [c:\derek\dr\git\src\core\loader_shared.c @ 228]
14 1f2aef5c 6115564f dynamorio!dynamo_thread_exit_common+0x3da [c:\derek\dr\git\src\core\dynamo.c @ 2459]
15 1f2aef78 613a6af2 dynamorio!dynamo_thread_exit+0x1f [c:\derek\dr\git\src\core\dynamo.c @ 2567]
16 1f2aefb8 613c0972 dynamorio!cleanup_and_terminate+0x4e [C:\derek\dr\git\build_x86_dbg_tests\core\CMakeFiles\dynamorio.dir\arch\x86\x86.asm.obj.s @ 1938]
17 1f2aefd0 613c7704 dynamorio!os_terminate+0x12 [c:\derek\dr\git\src\core\win32\os.c @ 1539]
18 1f2aefec 00000000 dynamorio!client_thread_target+0x164 [c:\derek\dr\git\src\core\win32\os.c @ 2699]
0:002> ?? dcontext->client_data
struct _client_data_t * 0x00000000
instrument_thread_exit() goes first, is the problem. I'm adding a debug-only dcontext->is_client_thread_exiting.
client.thread internal assert
<Attached to 2 threads in application C:\derek\appveyor\client.thread.exe (3784)> ASSERT FAILURE: C:\derek\dr\git\src\suite\tests\client-interface\thread.dll.c:115: (process_id_t)(ptr_uint_t) dr_get_tls_field(dr_get_current_drcontext()) == dr_get_process_id() + 1 ()
Adding diagnostics:
thread 4540 TLS is 0x000012b1 vs expected 0x000012b1
PR 210591: testing client transparency
thread 4540 TLS is 0x000012b1 vs expected 0x000012b1
thread 4464 TLS is 0x00000001 vs expected 0x000012b1
ASSERT FAILURE: C:\derek\dr\git\src\suite\tests\client-interface\thread.dll.c:119: (process_id_t)(ptr_uint_t) dr_get_tls_field(dr_get_current_drcontext()) == dr_get_process_id() + 1 ()
Soln: just set for all threads.