Title: Avoid locking registration state in unchained faulthandler signals by youknowdot · Pull Request #9902 · RustPython/RustPython · GitHub
Open Graph Title: Avoid locking registration state in unchained faulthandler signals by youknowdot · Pull Request #9902 · RustPython/RustPython
X Title: Avoid locking registration state in unchained faulthandler signals by youknowdot · Pull Request #9902 · RustPython/RustPython
Description: 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 Applies to Unix target_has_atomic="64". Other Unix targets retain the old implementation and its limitation; Windows is unchanged. chain=True still 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. Original descriptor identity is preserved, including dup2 redirection. This does not fix existing Python-file keepalive or concurrent descriptor-close/reuse lifetime issues. First installation has a narrow publication window: a handler may observe disabled state and return before registration finishes. This is not advertised as delivery guarantees during concurrent installation. Post-fork normal registration/writer-lock behavior remains unchanged. No new fork restriction or descriptor duplication is introduced. 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 Fresh Linux release build passed; all 32 host_env unit tests passed, including the new packed-config and interrupted-bookkeeping checks. Targeted host_env release Clippy with -D warnings passed. Full workspace/C-API tests and Clippy were not run. Canonical test_faulthandler: 51 tests, 11 skips, 4 existing expected failures, passed twice. Registration/file/fd/unregister/thread-label/chaining tests ran successfully. Skips cover Windows-only cases, unavailable _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. Actual RustPython no-chain stress: baseline 3/3 timed out after 8 seconds; candidate 3/3 completed in 0.26–0.34 seconds, registering 100,000 times while another thread sent SIGUSR1. The equivalent CPython 3.15.2 probe completed 3/3. ptrace was unavailable, so exact lock-site attribution is source-supported rather than debugger-proven. Original-fd dup2 redirection 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. Native 64-bit-atomic target configuration checked for Linux/macOS; non-atomic64 armv5te fallback inspected. Other OS execution/cross-compilation remains for CI. Draft only. Performance review needed Seven alternating local release-binary pairs, same Lib and setup: Case Baseline median Candidate median Change 100,000 registrations 0.1683 s 0.1796 s +6.7% 200,000 delivered signals 0.4523 s 0.4726 s +4.5% 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.
Open Graph Description: 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. g...
X Description: 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. g...
Opengraph URL: https://github.com/RustPython/RustPython/pull/9902
X: @github
Domain: github.com
| react-profiling | 0 |
| react-import-map | react,react-dom,react-dom/client,react-dom/profiling,react-is,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@b8488ee2c322 |
| route-pattern | /:user_id/:repository/pull/:id/files(.:format) |
| route-controller | pull_requests |
| route-action | files |
| fetch-nonce | v2:8e006134-031f-d7f7-c223-94dd2ae8f472 |
| current-catalog-service-hash | ae870bc5e265a340912cde392f23dad3671a0a881730ffdadd82f2f57d81641b |
| request-id | 88A8:2270F4:3016719:3FD008D:6B01DE32 |
| html-safe-nonce | 5d65d9e85685e4dc23ff33b5d8a9338b17e7f6f72251a216261fbe27e46d257e |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI4OEE4OjIyNzBGNDozMDE2NzE5OjNGRDAwOEQ6NkIwMURFMzIiLCJ2aXNpdG9yX2lkIjoiNjU0ODQ2NDIzNzc0Mjc3NTg1OCIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | e5e9552b2b8fa6f00eb49ca7d44db720955dbeee1da9cd5e459e2d35bb59cc0c |
| hovercard-subject-tag | pull_request:5350347563 |
| github-keyboard-shortcuts | repository,pull-request-list,pull-request-conversation,pull-request-files-changed,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/RustPython/RustPython/pull/9902/files |
| twitter:image | https://avatars.githubusercontent.com/u/336763669?s=400&v=4 |
| twitter:card | summary_large_image |
| og:image | https://avatars.githubusercontent.com/u/336763669?s=400&v=4 |
| og:image:alt | 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. g... |
| og:site_name | GitHub |
| og:type | object |
| hostname | github.com |
| expected-hostname | github.com |
| None | cc5dfdd32f62ebd3223cab3af3aa2b268d3605218237326a48a99d1efd89495c |
| turbo-cache-control | no-preview |
| diff-view | unified |
| go-import | github.com/RustPython/RustPython git https://github.com/RustPython/RustPython.git |
| octolytics-dimension-user_id | 39710557 |
| octolytics-dimension-user_login | RustPython |
| octolytics-dimension-repository_id | 135201145 |
| octolytics-dimension-repository_nwo | RustPython/RustPython |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 135201145 |
| octolytics-dimension-repository_network_root_nwo | RustPython/RustPython |
| turbo-body-classes | logged-out env-production page-responsive full-width |
| disable-turbo | true |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 8c77c9e8439031ad54c75a250694842892f693e1 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width