Dict watcher API is not thread-safe in free-threaded builds #145235
Copy link
Copy link
Closed
Labels
interpreter-core(Objects, Python, Grammar, and Parser dirs)(Objects, Python, Grammar, and Parser dirs)topic-free-threadingtype-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or error
Description
Bug report
Bug description:
PyDict_AddWatcher, PyDict_ClearWatcher, PyDict_Watch, PyDict_Unwatch, and _PyDict_SendEvent are not safe to call concurrently in free-threaded builds. The shared callback array and per-dict _ma_watcher_tag can race when watchers are registered, removed, or triggered from multiple threads.
CPython versions tested on:
CPython main branch
Operating systems tested on:
Linux
Linked PRs
- gh-145235: Make dict watcher API thread-safe for free-threaded builds #145233
- [3.15] gh-145235: Make dict watcher API thread-safe for free-threaded builds (gh-145233) #149690
- [3.14] gh-145235: Make dict watcher API thread-safe for free-threaded builds (gh-145233) #149691
Note: Running test.test_free_threading.test_dict_watcher (added in #145233) emits tsan warnings in the free-threaded tsan build.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
interpreter-core(Objects, Python, Grammar, and Parser dirs)(Objects, Python, Grammar, and Parser dirs)topic-free-threadingtype-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or error
Activity
gh-145235: Make dict watcher API thread-safe for free-threaded builds (…
[3.15] gh-145235: Make dict watcher API thread-safe for free-threaded…
[3.14] gh-145235: Make dict watcher API thread-safe for free-threaded…