Jinoh Kang (@iamahuman) commented about dlls/ntdll/unix/signal_x86_64.c:
EXCEPTION_RECORD rec = { 0 }; struct xcontext context; ucontext_t *ucontext = sigcontext; + int si_code;
if (handle_syscall_trap( sigcontext )) return;
rec.ExceptionAddress = (void *)RIP_sig(ucontext); save_context( &context, sigcontext );
- switch (siginfo->si_code) +#if defined(__APPLE__) + switch (TRAP_sig(ucontext))
I noticed that we already rely on `TRAP_SIG(ucontext)` to determine the correct exception in `segv_handler`. If we can trust `TRAP_SIG(ucontext)` over `siginfo->si_code` for `SIGTRAP` too in all platforms, perhaps it makes sense to make this switch unconditional. -- https://gitlab.winehq.org/wine/wine/-/merge_requests/408#note_3808