[FIX] replace fprintf(), exit() with write(), _exit() to async-safe at SIGSEGV signal handler#433
Closed
yoochangyeon wants to merge 1 commit into
Closed
Conversation
yoochangyeon
requested review from
nsavoire,
r1viollet and
sanchda
as code owners
January 15, 2025 00:21
r1viollet
reviewed
Jan 16, 2025
| (void)fprintf( | ||
| stderr, "ddprof[%d]: <%.*s> has encountered an error and will exit\n", | ||
| getpid(), static_cast<int>(str_version().size()), str_version().data()); | ||
| const char msg[] = "ddprof: encountered an error and will exit\n"; |
Collaborator
There was a problem hiding this comment.
Thanks for raising this. We have more work to improve crash tracking, though this would be a reasonable first step.
You are removing a minor info here (the si->si_addr), I'll add this back in while keeping your changes.
The GLIBC version can stay as is as we do not deploy that version (we use a musl build for the releases).
Collaborator
|
Closing this PR in favour of #435 |
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 join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
What does this PR do?
This PR replaces the usage of non-async-safe functions (fprintf, printf, exit) in the SIGSEGV handler with async-safe alternatives (write, _exit). This aims to ensure more reliable behavior when a segmentation fault occurs.
Motivation
https://docs.oracle.com/cd/E19455-01/806-5257/gen-26/index.html
When a SIGSEGV is triggered, the program’s state may already be corrupt. Using non-async-safe functions inside the signal handler can lead to reentrancy issues or additional faults. By switching to write and _exit, we minimize these risks and maintain a more stable crash-handling sequence.
Additional Notes
How to test the change?