the clear of TLS_SEG in emit_new_thread_dynamo_start() clobbers any app use of aux seg
This code in emit_new_thread_dynamo_start() seems problematic:
# ifdef X86
/* We avoid get_thread_id syscall in get_thread_private_dcontext()
* by clearing the segment register here (cheaper check than syscall)
* (xref PR 192231). If we crash prior to this point though, the
* signal handler will get the wrong dcontext, but that's a small window.
* See comments in get_thread_private_dcontext() for alternatives.
*/
APP(&ilist, XINST_CREATE_load_int
(dcontext, opnd_create_reg(REG_AX), OPND_CREATE_INT16(0)));
APP(&ilist, INSTR_CREATE_mov_seg
(dcontext, opnd_create_reg(SEG_TLS), opnd_create_reg(REG_AX)));
# endif
We swap to native, but then we clear the aux seg reg -- so if the app is using the aux reg too and isn't using the MSR won't we mess it up? Our init won't know that it's using a segment.