]> git.ipfire.org Git - thirdparty/Python/cpython.git/commit
gh-118362: Fix thread safety around lookups from the type cache in the face of concur...
authorDino Viehland <dinoviehland@meta.com>
Mon, 6 May 2024 17:50:35 +0000 (10:50 -0700)
committerGitHub <noreply@github.com>
Mon, 6 May 2024 17:50:35 +0000 (10:50 -0700)
commit5a1618a2c8c108b8c73aa9459b63f0dbd66b60f6
treea9b79e4cb8e0a9d1d648e21619382a03363c1f46
parente6b213ee3ffb05f067d30cb8bb45681887212444
gh-118362: Fix thread safety around lookups from the type cache in the face of concurrent mutators (#118454)

Add _PyType_LookupRef and use incref before setting attribute on type
Makes setting an attribute on a class and signaling type modified atomic
Avoid adding re-entrancy exposing the type cache in an inconsistent state by decrefing after type is updated
18 files changed:
Include/cpython/object.h
Include/cpython/pyatomic.h
Include/cpython/pyatomic_gcc.h
Include/cpython/pyatomic_msc.h
Include/cpython/pyatomic_std.h
Include/internal/pycore_dict.h
Include/internal/pycore_object.h
Lib/test/test_class.py
Lib/test/test_free_threading/test_type.py [new file with mode: 0644]
Misc/NEWS.d/next/Core and Builtins/2024-05-01-14-20-28.gh-issue-118492.VUsSfn.rst [new file with mode: 0644]
Modules/_collectionsmodule.c
Modules/_ctypes/_ctypes.c
Modules/_lsprof.c
Modules/_testcapi/gc.c
Objects/classobject.c
Objects/dictobject.c
Objects/object.c
Objects/typeobject.c