summaryrefslogtreecommitdiff
path: root/src/pal
diff options
context:
space:
mode:
authorAditya Mandaleeka <adityam@microsoft.com>2017-07-03 10:41:02 -0700
committerAditya Mandaleeka <adityam@microsoft.com>2017-07-05 17:00:49 -0700
commit94f2d05cd8e2f0d0be0e264b808dccb58b5d8f33 (patch)
tree2ad9f9ec580ab36dc13a803c863b49212bf89b93 /src/pal
parentf024e166d69ba4d82544e868a5544d7edece5e43 (diff)
downloadcoreclr-94f2d05cd8e2f0d0be0e264b808dccb58b5d8f33.tar.gz
coreclr-94f2d05cd8e2f0d0be0e264b808dccb58b5d8f33.tar.bz2
coreclr-94f2d05cd8e2f0d0be0e264b808dccb58b5d8f33.zip
Mask INJECT_ACTIVATION_SIGNAL while on alternate signal stack.
Diffstat (limited to 'src/pal')
-rw-r--r--src/pal/src/exception/signal.cpp30
1 files changed, 30 insertions, 0 deletions
diff --git a/src/pal/src/exception/signal.cpp b/src/pal/src/exception/signal.cpp
index b580ba4f51..3e28115909 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);
}
@@ -856,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",