Skip to content

Conversation

@colesbury
Copy link
Contributor

@colesbury colesbury commented Jan 30, 2026

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)

…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 <colesbury@gmail.com>
@colesbury colesbury merged commit 06f9c8c into python:3.14 Jan 30, 2026
51 checks passed
@colesbury colesbury deleted the backport-e666a01-3.14 branch January 30, 2026 17:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant