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

Fix stack overflow handling with SuperPMI #106495

Merged
merged 2 commits into from
Aug 16, 2024

Conversation

janvorli
Copy link
Member

When SuperPMI shared library is loaded last, its SIGSEGV handler is the first one that's executed. But since there is no coreclr runtime handler installed for it, it returns from the SwitchStackAndExecuteHandler in case of SIGSEGV. The remaining code in the SIGSEGV handler was not expecting that and thought that there was no stack overflow and attempted to run the hardware exception handler on the original stack of the thread, which obviously crashed since the original stack overflowed.
The fix is to make sure that we only call the previously registered signal handler in this case.

Close #84911

When SuperPMI shared library is loaded last, its SIGSEGV handler
is the first one that's executed. But since there is no coreclr runtime handler
installed for it, it returns from the SwitchStackAndExecuteHandler in case
of SIGSEGV. The remaining code in the SIGSEGV handler was not expecting that and
thought that there was no stack overflow and attempted to run the hardware exception
handler on the original stack of the thread, which obviously crashed since the original
stack overflowed.
The fix is to make sure that we only call the previously registered signal handler in
this case.

Close dotnet#84911
@janvorli janvorli added this to the 10.0.0 milestone Aug 15, 2024
@janvorli janvorli requested a review from jkotas August 15, 2024 19:35
@janvorli janvorli self-assigned this Aug 15, 2024
// hardware signal handler on the original stack.

if (GetCurrentPalThread() && IsRunningOnAlternateStack(context))
if (!isStackOverflow)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
if (!isStackOverflow)
else

?

@janvorli
Copy link
Member Author

/azp run runtime-coreclr superpmi-collect

Copy link

No pipelines are associated with this pull request.

@janvorli janvorli merged commit 9230f2b into dotnet:main Aug 16, 2024
90 checks passed
@github-actions github-actions bot locked and limited conversation to collaborators Sep 16, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Test failure baseservices\\exceptions\\stackoverflow\\stackoverflowtester\\stackoverflowtester.cmd
2 participants