summaryrefslogtreecommitdiff
path: root/src/pal
diff options
context:
space:
mode:
Diffstat (limited to 'src/pal')
-rw-r--r--src/pal/src/exception/seh-unwind.cpp9
-rw-r--r--src/pal/src/exception/signal.cpp36
-rw-r--r--src/pal/src/thread/process.cpp4
-rwxr-xr-xsrc/pal/tools/gen-buildsys-clang.sh2
4 files changed, 42 insertions, 9 deletions
diff --git a/src/pal/src/exception/seh-unwind.cpp b/src/pal/src/exception/seh-unwind.cpp
index ba43c2e..7746bbb 100644
--- a/src/pal/src/exception/seh-unwind.cpp
+++ b/src/pal/src/exception/seh-unwind.cpp
@@ -266,13 +266,8 @@ BOOL PAL_VirtualUnwind(CONTEXT *context, KNONVOLATILE_CONTEXT_POINTERS *contextP
// 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* signalContext = (CONTEXT*)(CONTEXTGetFP(context) + g_common_signal_handler_context_locvar_offset);
+ memcpy_s(context, sizeof(CONTEXT), signalContext, sizeof(CONTEXT));
return TRUE;
}
diff --git a/src/pal/src/exception/signal.cpp b/src/pal/src/exception/signal.cpp
index 57ae62e..10eecf7 100644
--- a/src/pal/src/exception/signal.cpp
+++ b/src/pal/src/exception/signal.cpp
@@ -411,7 +411,27 @@ extern "C" void signal_handler_worker(int code, siginfo_t *siginfo, void *contex
// TODO: First variable parameter says whether a read (0) or write (non-0) caused the
// fault. We must disassemble the instruction at record.ExceptionAddress
// to correctly fill in this value.
+
+ // Unmask the activation signal now that we are running on the original stack of the thread
+ sigset_t signal_set;
+ sigemptyset(&signal_set);
+ sigaddset(&signal_set, INJECT_ACTIVATION_SIGNAL);
+
+ int sigmaskRet = pthread_sigmask(SIG_UNBLOCK, &signal_set, NULL);
+ if (sigmaskRet != 0)
+ {
+ ASSERT("pthread_sigmask failed; error number is %d\n", sigmaskRet);
+ }
+
returnPoint->returnFromHandler = common_signal_handler(code, siginfo, context, 2, (size_t)0, (size_t)siginfo->si_addr);
+
+ // We are going to return to the alternate stack, so block the activation signal again
+ sigmaskRet = pthread_sigmask(SIG_BLOCK, &signal_set, NULL);
+ if (sigmaskRet != 0)
+ {
+ ASSERT("pthread_sigmask failed; error number is %d\n", sigmaskRet);
+ }
+
RtlRestoreContext(&returnPoint->context, NULL);
}
@@ -761,12 +781,13 @@ __attribute__((noinline))
static bool common_signal_handler(int code, siginfo_t *siginfo, void *sigcontext, int numParams, ...)
{
sigset_t signal_set;
+ CONTEXT signalContextRecord;
CONTEXT *contextRecord;
EXCEPTION_RECORD *exceptionRecord;
native_context_t *ucontext;
ucontext = (native_context_t *)sigcontext;
- g_common_signal_handler_context_locvar_offset = (int)((char*)&ucontext - (char*)__builtin_frame_address(0));
+ g_common_signal_handler_context_locvar_offset = (int)((char*)&signalContextRecord - (char*)__builtin_frame_address(0));
AllocateExceptionRecords(&exceptionRecord, &contextRecord);
@@ -809,6 +830,9 @@ static bool common_signal_handler(int code, siginfo_t *siginfo, void *sigcontext
}
contextRecord->ContextFlags |= CONTEXT_EXCEPTION_ACTIVE;
+
+ memcpy_s(&signalContextRecord, sizeof(CONTEXT), contextRecord, sizeof(CONTEXT));
+
// The exception object takes ownership of the exceptionRecord and contextRecord
PAL_SEHException exception(exceptionRecord, contextRecord);
@@ -852,6 +876,16 @@ void handle_signal(int signal_id, SIGFUNC sigfunc, struct sigaction *previousAct
#endif /* HAVE_SIGINFO_T */
sigemptyset(&newAction.sa_mask);
+#ifdef INJECT_ACTIVATION_SIGNAL
+ if ((additionalFlags & SA_ONSTACK) != 0)
+ {
+ // A handler that runs on a separate stack should not be interrupted by the activation signal
+ // until it switches back to the regular stack, since that signal's handler would run on the
+ // limited separate stack and likely run into a stack overflow.
+ sigaddset(&newAction.sa_mask, INJECT_ACTIVATION_SIGNAL);
+ }
+#endif
+
if (-1 == sigaction(signal_id, &newAction, previousAction))
{
ASSERT("handle_signal: sigaction() call failed with error code %d (%s)\n",
diff --git a/src/pal/src/thread/process.cpp b/src/pal/src/thread/process.cpp
index 6db9bf6..e22d268 100644
--- a/src/pal/src/thread/process.cpp
+++ b/src/pal/src/thread/process.cpp
@@ -2951,6 +2951,10 @@ PROCAbortInitialize()
{
*argv++ = "--triage";
}
+ else if (strcmp(envvar, "4") == 0)
+ {
+ *argv++ = "--full";
+ }
}
envvar = getenv("COMPlus_CreateDumpDiagnostics");
diff --git a/src/pal/tools/gen-buildsys-clang.sh b/src/pal/tools/gen-buildsys-clang.sh
index 9441877..132be93 100755
--- a/src/pal/tools/gen-buildsys-clang.sh
+++ b/src/pal/tools/gen-buildsys-clang.sh
@@ -173,8 +173,8 @@ cmake \
"-DCMAKE_NM=$llvm_nm" \
"-DCMAKE_OBJDUMP=$llvm_objdump" \
"-DCMAKE_BUILD_TYPE=$buildtype" \
- "-DCMAKE_ENABLE_CODE_COVERAGE=$code_coverage" \
"-DCMAKE_EXPORT_COMPILE_COMMANDS=1 " \
+ "-DCLR_CMAKE_ENABLE_CODE_COVERAGE=$code_coverage" \
"-DCLR_CMAKE_BUILD_TESTS=$build_tests" \
$cmake_extra_defines \
$__UnprocessedCMakeArgs \