← 输入框|github.com|刷新
Skip to content

[3.15] gh-158195: Do not hold the type lock during stop-the-world (gh-159972) - #160987

Draft
nascheme wants to merge 2 commits into
python:3.15from
nascheme:gh-158195-unpin-type-lock-3.15
Draft

nascheme wants to merge 2 commits into
python:3.15from
nascheme:gh-158195-unpin-type-lock-3.15

Conversation

@nascheme

Copy link
Copy Markdown
Member

Fixes the free-threaded deadlock described in gh-158195 by removing type-lock pinning. The type lock and class dict lock can now be released normally while a thread waits to stop the world, rather than remaining pinned across that wait.

This backport has a modification of GH-159972: avoid changing the default build behaviour. The following changes are now only for the free-threaded build:

  • fresh __bases__ tuple copying
  • type_new_copy_dict() and namespace-key normalization
  • addition of the new exact-Unicode dictionary helpers

This means that in the default build, you can still create a type with string-subclass keys. I'm not sure any code actually does that but it seems safer not to change that in a bugfix release.

Fixes the free-threaded deadlock described in pythongh-158195 by removing
type-lock pinning. The type lock and class dict lock can now be released
normally while a thread waits to stop the world, rather than remaining
pinned across that wait.
Avoid changing the default build behaviour.  The following changes are
now only for the free-threaded build:

- fresh __bases__ tuple copying
- type_new_copy_dict() and namespace-key normalization
- addition of the new exact-Unicode dictionary helpers

In the default build, you can still create a type with string-subclass
keys.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

topic-free-threading type-bug An unexpected behavior, bug, or error

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant