Skip to content

Commit e166eb6

Browse files
authored
Fix stack overflow reporting with multiple PALs (#107264)
* Fix stack overflow reporting with multiple PALs A recently reported issue in the stack overflow test running with superpmi collect has revealed that there is a problem when multiple shared libraries using coreclr PAL are loaded into the process. Each such library registers signal handlers, including the SIGSEGV one. The unexpected thing in the SIGSEGV handler in this scenario is the fact that the GetCurrentPalThread() returns NULL in the non-coreclr shared libraries in case the library didn't invoke any function that would create the thread object. That leads to the handler just writing "Stack overflow." to the console and then calling PROCAbort(). This abort causes the process to be torn down without reporting the stack overflow with full stack trace by the coreclr. This change fixes it by calling the previous registered handler instead aborting in this case. That gives the coreclr SIGSEGV handler a chance to do the reporting as expected. * Reflect PR feedback - move comment
1 parent ca74d03 commit e166eb6

File tree

1 file changed

+3
-4
lines changed

1 file changed

+3
-4
lines changed

src/coreclr/pal/src/exception/signal.cpp

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -646,15 +646,14 @@ static void sigsegv_handler(int code, siginfo_t *siginfo, void *context)
646646
{
647647
PROCAbort(SIGSEGV, siginfo);
648648
}
649-
650-
// The current executable (shared library) doesn't have hardware exception handler installed or opted to not to
651-
// handle it. So this handler will invoke the previously installed handler at the end of this function.
652649
}
653650
else
654651
{
655652
(void)!write(STDERR_FILENO, StackOverflowMessage, sizeof(StackOverflowMessage) - 1);
656-
PROCAbort(SIGSEGV, siginfo);
657653
}
654+
655+
// The current executable (shared library) doesn't have hardware exception handler installed or opted to not to
656+
// handle it. So this handler will invoke the previously installed handler at the end of this function.
658657
}
659658
else
660659
{

0 commit comments

Comments
 (0)