From f1a03d87c7d43820bca94c0a5a7945e132f3b0e7 Mon Sep 17 00:00:00 2001 From: Jan Vorlicek Date: Wed, 7 Oct 2015 14:21:36 +0200 Subject: 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. --- src/pal/src/exception/seh-unwind.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'src/pal/src/exception/seh-unwind.cpp') diff --git a/src/pal/src/exception/seh-unwind.cpp b/src/pal/src/exception/seh-unwind.cpp index 5a8c67160f..322515ad5e 100644 --- a/src/pal/src/exception/seh-unwind.cpp +++ b/src/pal/src/exception/seh-unwind.cpp @@ -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; } -- cgit v1.2.3