Repository navigation
Avoid locking registration state in unchained faulthandler signals - #9902
Merged
youknowone merged 1 commit intoNov 17, 2026
Merged
youknowone merged 1 commit into
youknowone merged 1 commit into
Conversation
Publish coherent fd and flag snapshots on atomic64 Unix targets. Preserve descriptor identity and existing chaining bookkeeping; restore errno on user-handler exits. This is a limited no-chain deadlock fix, not a solution for chained disposition races or descriptor ownership. Assisted-by: Codex:model-version-unavailable
Contributor
|
Caution Review failedThe pull request is closed.
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. |
youknowone
marked this pull request as ready for review
November 17, 2026 04:53
Codex Review Summary: ✅ CompletedThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
youknowone
approved these changes
Nov 17, 2026
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.
Summary
Fix the unchained user-signal registration deadlock on Unix targets with native 64-bit atomics, without changing the descriptor number or adding allocation/reclamation to signal handlers.
get_user_signal()currently locks the same mutex used by registration. A signal delivered while that thread holds the mutex can wait on itself. Publish the small(fd, enabled, all_threads, chain)configuration in a single atomic word instead; registration bookkeeping and previous dispositions remain separate. Restore entry errno on all normal user-handler exits.This is a narrowly scoped safety fix, not completion of
max_threads/C-stack/all-thread parity. No expected-failure markers are removed, dependencies changed, or CI configuration altered.Scope and remaining limitations
target_has_atomic="64". Other Unix targets retain the old implementation and its limitation; Windows is unchanged.chain=Truestill uses the existing mutex-based disposition path and can deadlock. Its restore/raise/reinstall versus unregister race is not solved. CPython v3.15.2 also uses restore/raise/reinstall; that is not evidence of race-free behavior in RustPython.dup2redirection. This does not fix existing Python-file keepalive or concurrent descriptor-close/reuse lifetime issues.The previously explored heap snapshots/duplicated descriptors are not used: duplicated descriptors would change observable redirection semantics, while reclamation introduces unrelated lifetime/fork problems.
Validation
-D warningspassed. Full workspace/C-API tests and Clippy were not run.test_faulthandler: 51 tests, 11 skips, 4 existing expected failures, passed twice. Registration/file/fd/unregister/thread-label/chaining tests ran successfully._testcapi, disabled walltime resource, unavailable stack-overflow hook and the existing GIL-disabled fatal-all-thread restriction. Existing extension-module/C-stack/native-thread-fatal/max-thread failures remain marked unchanged.dup2redirection and ordinary post-fork unregister/re-register/dump probes match baseline behavior. These do not prove race-free concurrent descriptor closure or fork while a writer holds its mutex.Performance review needed
Seven alternating local release-binary pairs, same Lib and setup:
A shorter 20,000-signal measurement also showed +8.3%. These are narrow microbenchmarks, not zero-regression evidence. The available baseline has identical pre-change faulthandler code and build features but includes unrelated sampling-profiler changes; binary layout/noise and the separate errno correction prevent attributing all timing differences solely to the atomic load. Treat this as a safety improvement with performance still requiring review, not merge-ready.