-
-
Notifications
You must be signed in to change notification settings - Fork 31.7k
PyType_AddWatcher
and friends are not thread safe in free-threading
#131544
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
I think it may be fine to just document that |
I'm pretty sure that Cinder does this already (@mpage ?) and I'm not sure there are any other current users of the API: |
Hmm, I think that we can use CAS operation at Is there any concerns to add extra atomic operations for those APIs at free-threading? |
If you rely on atomics, you have to use them for every access, so also every read of |
(cherry picked from commit 25275bd) Co-authored-by: Donghee Na <[email protected]>
PyType_AddWatcher
andPyType_ClearWatcher
are not thread safe as it modifies the interp's type watchers non-atomically.PyType_AddWatcher
:cpython/Objects/typeobject.c
Lines 949 to 963 in d3f6063
PyType_ClearWatcher
:cpython/Objects/typeobject.c
Lines 980 to 989 in d3f6063
I think adding and removing of type watchers is a rare event so maybe instead of adding atomics or locks it would be better to change them to use stop-the-world pause event.
Linked PRs
The text was updated successfully, but these errors were encountered: