FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

gh-158194: Pin the type lock in PyType_Freeze() by nascheme · Pull Request #158674 · python/cpython · GitHub

Repository navigation

gh-158194: Pin the type lock in PyType_Freeze() - #158674

Open
nascheme wants to merge 1 commit into
python:mainfrom
nascheme:gh-158194-type-freeze-pin
Open

nascheme wants to merge 1 commit into
python:mainfrom
nascheme:gh-158194-type-freeze-pin

Conversation

nascheme commented Oct 3, 2026 •
edited by bedevere-app Bot
Loading

Copy link
Copy Markdown
Member

Fix PyType_Freeze releasing the type lock while waiting for a stop-the-world pause in the free-threaded build. Another thread could modify the type before the frozen type's caches were invalidated, and the release could deadlock against a thread waiting for the pause with the type lock held.

PyType_Freeze() stopped the world under the type lock without pinning
it, so the lock could be released while waiting for the pause.  Pin it
with type_lock_prevent_release() like the other type-lock callers of
types_stop_world().

nascheme commented Oct 3, 2026

Copy link
Copy Markdown
Member Author

This fix in this PR is the same code change as suggested by @scasella, without the additional code comment.

johng commented Oct 22, 2026 •
edited
Loading

Copy link
Copy Markdown
Contributor

Is it possible to add a test that exposes the original issue being fixed?

(I can see this might not be consistently reproducible though, not sure what the precedence is for that for)

Copy link
Copy Markdown
Member Author

Is it possible to add a test that exposes the original issue being fixed?

Yeah, that would be a good idea. I would guess it's possible.

Copy link
Copy Markdown
Member Author

This probably needs a re-write, given GH-159972.

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

Labels

awaiting core review needs backport to 3.14 bugs and security fixes needs backport to 3.15 bugs and security fixes topic-free-threading type-bug An unexpected behavior, bug, or error

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants


Back | FazBrowse Home | New Git URL