Skip to content

Reinit critical parking_lot locks after fork in child process#6972

Draft
youknowone wants to merge 1 commit intoRustPython:mainfrom
youknowone:reinit-after-fork
Draft

Reinit critical parking_lot locks after fork in child process#6972
youknowone wants to merge 1 commit intoRustPython:mainfrom
youknowone:reinit-after-fork

Conversation

@youknowone
Copy link
Member

@youknowone youknowone commented Feb 3, 2026

close #6963

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Feb 3, 2026

Important

Review skipped

Draft detected.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

  • 🔍 Trigger a full review
✨ Finishing touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

After fork(), only the calling thread survives. Locks held by
dead parent threads stay locked forever, causing deadlocks when
the child tries to acquire them.

- Add reinit_pymutex_after_fork / reinit_pyrwlock_after_fork
  utilities that zero the raw lock bytes directly
- Reset all PyGlobalState locks, thread-handle locks, and the
  import lock (IMP_LOCK) at the start of py_os_after_fork_child
- Remove unlock() calls from _at_fork_reinit — unlock_slow()
  would attempt to unpark stale waiters from dead threads
- Replace try_lock() with lock() in after_fork_child now that
  locks are guaranteed to be in unlocked state

Note that this does not resolve any data deadlock issue
@github-actions
Copy link
Contributor

github-actions bot commented Feb 3, 2026

📦 Library Dependencies

The following Lib/ modules were modified. Here are their dependencies:

[x] lib: cpython/Lib/asyncio
[ ] test: cpython/Lib/test/test_asyncio (TODO: 37)

dependencies:

  • asyncio

dependent tests: (8 tests)

  • asyncio: test_asyncio test_builtin test_contextlib_async test_inspect test_logging test_os test_sys_settrace test_unittest

Legend:

  • [+] path exists in CPython
  • [x] up-to-date, [ ] outdated

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant