From: Brendan Shanks bshanks@codeweavers.com
--- dlls/ntdll/unix/signal_x86_64.c | 9 +++++++++ 1 file changed, 9 insertions(+)
diff --git a/dlls/ntdll/unix/signal_x86_64.c b/dlls/ntdll/unix/signal_x86_64.c index 58496685398..a340341bd1c 100644 --- a/dlls/ntdll/unix/signal_x86_64.c +++ b/dlls/ntdll/unix/signal_x86_64.c @@ -841,6 +841,15 @@ static inline ucontext_t *init_handler( void *sigcontext ) #elif defined __APPLE__ struct ntdll_thread_data *thread_data = (struct ntdll_thread_data *)&get_current_teb()->GdiTebBatch; _thread_set_tsd_base( (uint64_t)((struct amd64_thread_data *)thread_data->cpu_data)->pthread_teb ); + + /* When in a syscall, CS will be set to the kernel's selector (0x07, SYSCALL_CS in xnu source) + * instead of the user selector (cs64_sel: 0x2b, USER64_CS). + * Fix up sigcontext so later code can compare it to cs64_sel. + * + * Only applies on Intel, not under Rosetta. + */ + if (CS_sig((ucontext_t *)sigcontext) != cs32_sel) + CS_sig((ucontext_t *)sigcontext) = cs64_sel; #endif return sigcontext; }