[3.14] gh-144295: Fix data race in dict method lookup and global load… · python/cpython@06f9c8c · GitHub
Skip to content

Commit 06f9c8c

Browse files
authored
[3.14] gh-144295: Fix data race in dict method lookup and global load (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)
1 parent 49ce23f commit 06f9c8c

2 files changed

Lines changed: 25 additions & 1 deletion

File tree

Lib/test/test_free_threading/test_dict.py

Lines changed: 22 additions & 0 deletions

Objects/dictobject.c

Lines changed: 3 additions & 1 deletion

0 commit comments

Comments
 (0)