[Backtracing][Linux] Correctly handle signals from other processes.#89461
Draft
al45tair wants to merge 1 commit into
Draft
[Backtracing][Linux] Correctly handle signals from other processes.#89461al45tair wants to merge 1 commit into
al45tair wants to merge 1 commit into
Conversation
Contributor
Author
|
@swift-ci Please smoke test |
weissi
reviewed
May 27, 2026
| // this case what we want to do is stop the memory server and | ||
| // reinstall the signal handlers in order that we catch future | ||
| // crashes. | ||
| memserver_stop(); |
Contributor
There was a problem hiding this comment.
@al45tair I don't love this because that's functionality that's only accessible from PID 1. Would it not be possible to re-raise the signal in a way that's guaranteed to kill the process even as pid 1?
Contributor
Author
There was a problem hiding this comment.
It won't ever kill the process if it's PID 1, because Linux protects PID 1 processes from being killed by crashes(!)
Trying to terminate would actually change the standard behaviour for PID 1. I did think about it, but I don't think we should do that.
It's possible to `kill -SEGV` or `kill -ILL` a Swift program; when this happens, we need to be aware and handle it slightly differently to normal, because the signal we get doesn't have the same information attached to it that it normally would. Additionally we need to make sure the behaviour is as expected. That means, for PID 1, the process should output a backtrace *and continue running*, while in the normal case the process should terminate with a status code reflecting the signal that was delivered. rdar://177740814
c33828b to
7663621
Compare
Contributor
Author
|
@swift-ci Please smoke test |
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.
It's possible to
kill -SEGVorkill -ILLa Swift program; when this happens, we need to be aware and handle it slightly differently to normal, because the signal we get doesn't have the same information attached to it that it normally would.Additionally we need to make sure the behaviour is as expected. That means, for PID 1, the process should output a backtrace and continue running, while in the normal case the process should terminate with a status code reflecting the signal that was delivered.
rdar://177740814