Fix stack overflow handling with SuperPMI#106495
Merged
janvorli merged 2 commits intodotnet:mainfrom Aug 16, 2024
Merged
Conversation
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
jkotas
reviewed
Aug 15, 2024
| // hardware signal handler on the original stack. | ||
|
|
||
| if (GetCurrentPalThread() && IsRunningOnAlternateStack(context)) | ||
| if (!isStackOverflow) |
Member
There was a problem hiding this comment.
Suggested change
| if (!isStackOverflow) | |
| else |
?
jkotas
approved these changes
Aug 15, 2024
Member
Author
|
/azp run runtime-coreclr superpmi-collect |
|
No pipelines are associated with this pull request. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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