Skip to content

gh-158973: Reset the warnings lock after fork in the child - #158974

Draft
nascheme wants to merge 3 commits into
python:mainfrom
nascheme:gh-158973-reset-warnings-lock
Draft

nascheme wants to merge 3 commits into
python:mainfrom
nascheme:gh-158973-reset-warnings-lock

Conversation

@nascheme

@nascheme nascheme commented Oct 7, 2026 •

Copy link
Copy Markdown
Member

Reset the warnings lock in the child after fork, before clearing other threads’ states. This prevents deadlocks when their finalizers issue warnings and the lock was held by a thread that no longer exists. Record ownership before fork so the child can preserve the lock’s recursion depth and update its owner ID if the forking thread held it. Adds regression tests for child-cleanup warnings and recursive ownership across fork.

The PR was developed with assistance from GPT 6.1 Sol.

@nascheme nascheme added type-bug An unexpected behavior, bug, or error topic-free-threading needs backport to 3.14 bugs and security fixes needs backport to 3.15 pre-release feature fixes, bugs and security fixes labels Oct 7, 2026
@nascheme
nascheme requested a review from ngoldbaum October 7, 2026 17:20
Add _PyRecursiveMutex_at_fork_reinit() helper function.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

needs backport to 3.14 bugs and security fixes needs backport to 3.15 pre-release feature fixes, bugs and security fixes type-bug An unexpected behavior, bug, or error

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant