Fix parking lot hash table after fork#6963
Fix parking lot hash table after fork#6963youknowone wants to merge 2 commits intoRustPython:mainfrom
Conversation
|
Important Review skippedDraft detected. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: Path: .coderabbit.yml Review profile: CHILL Plan: Pro Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
✨ Finishing Touches🧪 Generate unit tests (beta)
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. Comment |
d95e4ab to
b516c63
Compare
📦 Library DependenciesThe following Lib/ modules were modified. Here are their dependencies: [ ] lib: cpython/Lib/asyncio dependencies:
dependent tests: (7 tests)
[ ] lib: cpython/Lib/concurrent dependencies:
dependent tests: (16 tests)
[ ] lib: cpython/Lib/multiprocessing dependencies:
dependent tests: (11 tests)
Legend:
|
|
Code has been automatically formatted The code in this PR has been formatted using:
git pull origin fork-safety |
dd81afd to
6bc44ba
Compare
|
Great! Does this PR makes #7269 obsolete? |
parking_lot_core's global HASHTABLE retains stale ThreadData after fork(), causing segfaults when contended locks enter park(). Use the patched version from youknowone/parking_lot (rustpython branch) which registers a pthread_atfork handler to reset the hash table. Unskip test_asyncio TestFork. Add Manager+fork integration test.
With parking_lot_core's HASHTABLE now properly reset via pthread_atfork, fork-related segfaults and connection errors in multiprocessing tests should be resolved. Remove skip/expectedFailure markers from: - test_concurrent_futures/test_wait.py (6 tests) - test_concurrent_futures/test_process_pool.py (1 test) - test_multiprocessing_fork/test_manager.py (all WithManagerTest*) - test_multiprocessing_fork/test_misc.py (5 tests) - test_multiprocessing_fork/test_threads.py (2 tests) - _test_multiprocessing.py (3 tests)
parking_lot_core maintains a global hash table (HASHTABLE) mapping lock addresses to queues of parked threads. Each bucket holds a linked list of ThreadData pointers.
fork() copies all memory but only one thread survives in the child. The hash table still references ThreadData of the dead threads, WordLocks held by them will never be released, and queue pointers become stale. When the child later hits a contended lock, park() follows these stale pointers and segfaults.
parking_lot_core currently has no such handling for child process
Issue reported to parking_lot Amanieu/parking_lot#515