|author||Jan Vorlicek <email@example.com>||2015-10-07 14:21:36 +0200|
|committer||Jan Vorlicek <firstname.lastname@example.org>||2015-10-07 14:21:36 +0200|
Fix OSX hardware exception handling
In my recent change that has added the runtime suspension for OSX, I have also added a fix for the unwind info of the PAL_DispatchExceptionWrapper function. It turns out that I've made a mistake in the offset in the set_cfa_register and it has broken hardware exception handling on OSX since the unwinder was not able to unwind correctly through the wrapper. It also turns out that the same wrong offset in set_cfa_register is in the ActivationHelperWrapper.S, but in that function, the unwinding still works correctly. I've actually verified that with both the wrong and the correct offset, the unwinder gets the same correct RSP / RBP at the time of the exception. So I believe linked ignored the DWARF unwind info and used compact unwind info instead that it was able to derive correctly on its own. Also, the allocate_stack was incorrectly placed before the set_cfa_register, which again didn't cause a problem due to the DWARF info being ignored. The issue with this one was that it updates the CFA, but the CFA offset is relative to RBP at that point and RBP didn't change. As an additional fix, there was a problem in PAL_VirtualUnwind that @sergiy-k has spotted. The return value of the recently added unw_is_signal_frame call was overwriting the status code returned by the unw_step that we use on OSX to detect walking out of stack.
Diffstat (limited to 'src/pal/src/exception/seh-unwind.cpp')
1 files changed, 1 insertions, 2 deletions
diff --git a/src/pal/src/exception/seh-unwind.cpp b/src/pal/src/exception/seh-unwind.cpp
index 5a8c67160f..322515ad5e 100644
@@ -294,8 +294,7 @@ BOOL PAL_VirtualUnwind(CONTEXT *context, KNONVOLATILE_CONTEXT_POINTERS *contextP
// Check if the frame we have unwound to is a frame that caused
// synchronous signal, like a hardware exception and record it
// in the context flags.
- st = unw_is_signal_frame(&cursor);
- if (st > 0)
+ if (unw_is_signal_frame(&cursor) > 0)
context->ContextFlags |= CONTEXT_EXCEPTION_ACTIVE;