diff options
author | Mike McLaughlin <mikem@microsoft.com> | 2016-01-15 13:57:47 -0800 |
---|---|---|
committer | Mike McLaughlin <mikem@microsoft.com> | 2016-01-26 01:50:03 -0800 |
commit | 76c9396a735ba1e311d4865f95b2454321546820 (patch) | |
tree | 7411b18b526be6a5b2d6509a555468d73e6a4e54 /src/pal/src/arch | |
parent | 431f7ff1150561a9d27e29c155706e279328446a (diff) | |
download | coreclr-76c9396a735ba1e311d4865f95b2454321546820.tar.gz coreclr-76c9396a735ba1e311d4865f95b2454321546820.tar.bz2 coreclr-76c9396a735ba1e311d4865f95b2454321546820.zip |
Fix OSX bps for PC-relative instructions.
Changed the mach exception handling to always hijack/send the exception back to the faulting
thread. Once running back in the faulting thread in PAL_DispatchException if the VM/debugger
code/hardware exception catching doesn't want this exception the exception message is forwarded
to the next exception port if one. Otherwise the process is aborted.
If the exception is forwarded, the faulting thread just busy waits until it gets hijacked
again by the next PAL exception thread in the system.
The exception message is always sent success as a reply after after the faulting thread is
hijacked. All the reply forwarding logic has been removed. This means we assume that OSX
default action for the unhandled exception is to abort the process. We don't reply with
KERN_FAILURE like before when the exception is unhandled. This also means that any third
party code hooking exception ports at the task or host level are not sent the exception
message.
The exception message is now also passed to PAL_DispatchException along with the ExceptionRecord
and Context so it can be used to forward the message if the VM doesn't want it (via a new function
called ForwardMachException).
Removed creating the reply port MachMessage::ForwardNotification and handle/ignore replies
in worker thread.
The original hijack logic queried the faulting thread's current state to build the thread CONTEXT
and the ExceptionRecord. Because the faulting thread runs now and forwards the exception notification
in its context, the hijack logic needs to use the thread state from the message to build the thread
CONTEXT. Refactored CONTEXT_GetThreadContextFromThreadState out of CONTEXT_GetThreadContextFromPort
as a part of this. Also needed to deal with x86_THREAD_STATE thread state flavor (which can be either
32 or 64 bit) instead of the x86_THREAD_STATE32/x86_THREAD_STATE64 explicitly used to get the thread
state in the original code.
Removed the code in ExceptionRecordFromMessage (formerly known as exception_from_trap_code) to
explicitly get the fault address from the thread instead of using the extra "code" in the exception
message to fill in the ExceptionInformation[1] field for access violations. Getting the faulting
address from the thread port doesn't work if the exception was forwarded and the "code" in the
exception message is accurate.
Since ICLRRuntimeHost2::RegisterMacEHPort() isn't implemented or used anymore and to simplify
the MAC exception code, removed s_TopExceptionPort and the top/bottom exception port logic.
Removed the s_ExceptionPortSet and just use s_ExceptionPort directly because we no longer
wait to receive messages from the reply port when forwarding the exception.
General cleanup. Renaming functions not to have underscores and locals not have the first letter
capitalized.
renamed:
catch_exception_raise -> HijackFaultingThread
exception_from_trap_code -> ExceptionRecordFromMessage
removed:
malloc_zone_t *s_pExecutableHeap
struct ForwardedNotification
PROCThreadFromMachPort(mach_port_t hTargetThread)
IsWithinCoreCLR(void *pAddr)
all the malloc_zone utilities in machexception.cpp
IsHandledException(MachMessage *pNotification, CorUnix::CPalThread *pThread)
Diffstat (limited to 'src/pal/src/arch')
-rw-r--r-- | src/pal/src/arch/i386/dispatchexceptionwrapper.S | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/src/pal/src/arch/i386/dispatchexceptionwrapper.S b/src/pal/src/arch/i386/dispatchexceptionwrapper.S index 26aeb70ae7..b055407e08 100644 --- a/src/pal/src/arch/i386/dispatchexceptionwrapper.S +++ b/src/pal/src/arch/i386/dispatchexceptionwrapper.S @@ -18,9 +18,9 @@ #include "unixasmmacros.inc" #if defined(__x86_64__) -#define PAL_DISPATCHEXCEPTION __Z21PAL_DispatchExceptionmmmmmmP8_CONTEXTP17_EXCEPTION_RECORD +#define PAL_DISPATCHEXCEPTION __Z21PAL_DispatchExceptionmmmmmmP8_CONTEXTP17_EXCEPTION_RECORDP11MachMessage #else //!defined(_AMD64_) -#define PAL_DISPATCHEXCEPTION __Z21PAL_DispatchExceptionP8_CONTEXTP17_EXCEPTION_RECORD +#define PAL_DISPATCHEXCEPTION __Z21PAL_DispatchExceptionP8_CONTEXTP17_EXCEPTION_RECORDP11MachMessage #endif // defined(_AMD64_) // Offset of the return address from the PAL_DISPATCHEXCEPTION in the PAL_DispatchExceptionWrapper @@ -34,13 +34,14 @@ C_FUNC(PAL_DispatchExceptionReturnOffset): // unwinding behavior is equivalent to any standard function having // an ebp frame. It is analogous to the following source file. // -// void PAL_DispatchException(CONTEXT *pContext, EXCEPTION_RECORD *pExceptionRecord); +// void PAL_DispatchException(CONTEXT *pContext, EXCEPTION_RECORD *pExceptionRecord, MachMessage *pMessage); // // extern "C" void PAL_DispatchExceptionWrapper() // { // CONTEXT Context; // EXCEPTION_RECORD ExceptionRecord; -// PAL_DispatchException(&Context, &ExceptionRecord); +// MachMessage Message; +// PAL_DispatchException(&Context, &ExceptionRecord, &Message); // } // |