From af3af9d048e824394bdff00fa6fd687f93d612f4 Mon Sep 17 00:00:00 2001 From: Ryan Houdek Date: Sun, 22 Aug 2021 21:06:44 -0700 Subject: [PATCH] x86: Fixes siginfo_t si_addr for SIGBUS/SIGSEGV si_addr is set to the address that is trying to be accessed, not the RIP that is trying to access it. We just need to copy our host value over for this. SIGFPE and SIGILL we still don't have a good answer for. --- .../FEXCore/Source/Interface/Core/Dispatcher/Dispatcher.cpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/External/FEXCore/Source/Interface/Core/Dispatcher/Dispatcher.cpp b/External/FEXCore/Source/Interface/Core/Dispatcher/Dispatcher.cpp index 73cc7bf2b..5f0eed5cd 100644 --- a/External/FEXCore/Source/Interface/Core/Dispatcher/Dispatcher.cpp +++ b/External/FEXCore/Source/Interface/Core/Dispatcher/Dispatcher.cpp @@ -274,6 +274,12 @@ bool Dispatcher::HandleGuestSignal(int Signal, void *info, void *ucontext, Guest switch (Signal) { case SIGSEGV: case SIGBUS: + // Macro expansion to get the si_addr + // This is the address trying to be accessed, not the RIP + guest_siginfo->_sifields._sigfault.addr = static_cast(reinterpret_cast(HostSigInfo->si_addr)); + break; + case SIGFPE: + case SIGILL: // Macro expansion to get the si_addr // Can't really give a real result here. Pull from the context for now guest_siginfo->_sifields._sigfault.addr = Frame->State.rip;