Skip to content

Conversation

colesbury
Copy link
Contributor

Description

Fixes potential thread-safety issues if types are concurrently registered while get_local_type_info() is called in free threaded Python.

Use the internals mutex to also protect local_internals. This keeps the locking strategy simpler, and we already follow this pattern in some places, such as pybind11_meta_dealloc.

Fixes #5799

Suggested changelog entry:

  • Fix thread-safety issues if types are concurrently registered while get_local_type_info() is called in free threaded Python.

Fixes potential thread-safety issues if types are concurrently
registered while `get_local_type_info()` is called in free threaded
Python.

Use the `internals` mutex to also protect `local_internals`. This
keeps the locking strategy simpler, and we already follow this pattern
in some places, such as `pybind11_meta_dealloc`.
@rwgk
Copy link
Collaborator

rwgk commented Oct 6, 2025

@swolchok @oremanj any chance one of you could help out reviewing this PR?

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.

[BUG]: local_internals appear very thread-unsafe
2 participants