Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add debugging checks for stack overflow tests failure #111867

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions src/coreclr/pal/src/exception/signal.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -606,6 +606,12 @@ static bool SwitchStackAndExecuteHandler(int code, siginfo_t *siginfo, void *con

#endif // !HAVE_MACH_EXCEPTIONS

// Temporary locals to debug issue https://github.com/dotnet/runtime/issues/110173
static SIZE_T stackOverflowThreadId = -1;
static const char StackOverflowOnTheSameThreadMessage[] = "Stack overflow occurred on the same thread again!\n";
static const char StackOverflowHandlerReturnedMessage[] = "Stack overflow handler has returned!\n";
//

/*++
Function :
sigsegv_handler
Expand Down Expand Up @@ -638,14 +644,26 @@ static void sigsegv_handler(int code, siginfo_t *siginfo, void *context)
// We have only one stack for handling stack overflow preallocated. We let only the first thread that hits stack overflow to
// run the exception handling code on that stack (which ends up just dumping the stack trace and aborting the process).
// Other threads are held spinning and sleeping here until the process exits.

// Temporary check to debug issue https://github.com/dotnet/runtime/issues/110173
if (stackOverflowThreadId == THREADSilentGetCurrentThreadId())
{
(void)!write(STDERR_FILENO, StackOverflowOnTheSameThreadMessage, sizeof(StackOverflowOnTheSameThreadMessage) - 1);
}

while (true)
{
sleep(1);
}
}
else
{
stackOverflowThreadId = THREADSilentGetCurrentThreadId();
}

if (SwitchStackAndExecuteHandler(code | StackOverflowFlag, siginfo, context, (size_t)handlerStackTop))
{
(void)!write(STDERR_FILENO, StackOverflowHandlerReturnedMessage, sizeof(StackOverflowHandlerReturnedMessage) - 1);
PROCAbort(SIGSEGV, siginfo);
}
}
Expand Down
Loading