-
-
Notifications
You must be signed in to change notification settings - Fork 34k
gh-144295: Fix data race in dict method lookup and global load #144312
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
Conversation
In `_PyDict_GetMethodStackRef`, only use the fast-path unicode lookup when the dict is owned by the current thread or already marked as shared. This prevents a race between the lookup and concurrent dict resizes, which may free the PyDictKeysObject (i.e., it ensures that the resize uses QSBR). Address a similar issue in `_Py_dict_lookup_threadsafe_stackref` by calling `ensure_shared_on_read()`.
|
Thanks @colesbury for the PR 🌮🎉.. I'm working now to backport this PR to: 3.14. |
|
Sorry, @colesbury, I could not cleanly backport this to |
…l load (pythongh-144312) In `_PyDict_GetMethodStackRef`, only use the fast-path unicode lookup when the dict is owned by the current thread or already marked as shared. This prevents a race between the lookup and concurrent dict resizes, which may free the PyDictKeysObject (i.e., it ensures that the resize uses QSBR). Address a similar issue in `_Py_dict_lookup_threadsafe_stackref` by calling `ensure_shared_on_read()`. (cherry picked from commit e666a01) Co-authored-by: Sam Gross <[email protected]>
|
GH-144346 is a backport of this pull request to the 3.14 branch. |
…gh-144312) (#144346) In `_Py_dict_lookup_threadsafe_stackref`, call `ensure_shared_on_read()` to prevent a race between the lookup and concurrent dict resizes, which may free the PyDictKeysObject (i.e., it ensures that the resize uses QSBR). (cherry picked from commit e666a01)
|
In
_PyDict_GetMethodStackRef, only use the fast-path unicode lookup when the dict is owned by the current thread or already marked as shared. This prevents a race between the lookup and concurrent dict resizes, which may free the PyDictKeysObject (i.e., it ensures that the resize uses QSBR).Address a similar issue in
_Py_dict_lookup_threadsafe_stackrefby callingensure_shared_on_read().new_keys_objectindictobject.c#144295