mirror of
https://github.com/izzy2lost/xenia-edge.git
synced 2026-07-06 00:20:26 -07:00
[Base/macOS] Align ucontext_t copy in arm64 signal handler
Co-Authored-By: Will Martin <wmarti@bu.edu>
This commit is contained in:
@@ -35,8 +35,17 @@ std::pair<ExceptionHandler::Handler, void*> handlers_[kMaxHandlerCount];
|
||||
|
||||
static void ExceptionHandlerCallback(int signal_number, siginfo_t* signal_info,
|
||||
void* signal_context) {
|
||||
#if XE_PLATFORM_MAC && XE_ARCH_ARM64
|
||||
// The Darwin kernel may pass an unaligned ucontext_t pointer to signal
|
||||
// handlers; copy into an aligned local before reading. mcontext_t is a
|
||||
// pointer on Mac, so writes still reach kernel storage via the pointer.
|
||||
alignas(16) ucontext_t ucontext_storage;
|
||||
std::memcpy(&ucontext_storage, signal_context, sizeof(ucontext_t));
|
||||
mcontext_t& mcontext = ucontext_storage.uc_mcontext;
|
||||
#else
|
||||
mcontext_t& mcontext =
|
||||
reinterpret_cast<ucontext_t*>(signal_context)->uc_mcontext;
|
||||
#endif
|
||||
|
||||
HostThreadContext thread_context;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user