diff options
author | Jan Vorlicek <janvorli@microsoft.com> | 2017-06-16 13:23:34 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-06-16 13:23:34 +0200 |
commit | b594d588bc8a7778c30cf0445599ce97cc2edac9 (patch) | |
tree | 80eca90a5f4e5484b4fedefb3597148b804c0813 /src/pal/src/exception/seh-unwind.cpp | |
parent | 23cbc3e9a2d8b0602a8e154b15b2a11ced71c17f (diff) | |
download | coreclr-b594d588bc8a7778c30cf0445599ce97cc2edac9.tar.gz coreclr-b594d588bc8a7778c30cf0445599ce97cc2edac9.tar.bz2 coreclr-b594d588bc8a7778c30cf0445599ce97cc2edac9.zip |
Fix chained hardware exception handling on Unix (#12316)
There is an issue when hardware exception occurs while handling another hardware exception. In such case,
the exception unwinding ends up in an infinite loop. It is caused by the kernel reusing the same location
for signal handler context.
The fix is to use the windows style context local variable in the common_signal_handler that contains
the right context - it is the original signal context converted to windows style context.
Diffstat (limited to 'src/pal/src/exception/seh-unwind.cpp')
-rw-r--r-- | src/pal/src/exception/seh-unwind.cpp | 11 |
1 files changed, 3 insertions, 8 deletions
diff --git a/src/pal/src/exception/seh-unwind.cpp b/src/pal/src/exception/seh-unwind.cpp index ba43c2e725..360ea3e987 100644 --- a/src/pal/src/exception/seh-unwind.cpp +++ b/src/pal/src/exception/seh-unwind.cpp @@ -261,18 +261,13 @@ BOOL PAL_VirtualUnwind(CONTEXT *context, KNONVOLATILE_CONTEXT_POINTERS *contextP #ifndef __APPLE__ // Check if the PC is the return address from the SEHProcessException in the common_signal_handler. - // If that's the case, extract its local variable containing the native_context_t of the hardware + // If that's the case, extract its local variable containing the windows style context of the hardware // exception and return that. This skips the hardware signal handler trampoline that the libunwind // cannot cross on some systems. if ((void*)curPc == g_SEHProcessExceptionReturnAddress) { - ULONG contextFlags = CONTEXT_CONTROL | CONTEXT_INTEGER | CONTEXT_FLOATING_POINT | CONTEXT_EXCEPTION_ACTIVE; - - #if defined(_AMD64_) - contextFlags |= CONTEXT_XSTATE; - #endif - size_t nativeContext = *(size_t*)(CONTEXTGetFP(context) + g_common_signal_handler_context_locvar_offset); - CONTEXTFromNativeContext((const native_context_t *)nativeContext, context, contextFlags); + CONTEXT* nativeContext = *(CONTEXT**)(CONTEXTGetFP(context) + g_common_signal_handler_context_locvar_offset); + memcpy_s(context, sizeof(CONTEXT), nativeContext, sizeof(CONTEXT)); return TRUE; } |