https://github.com/python/cpython/commit/1e4a4c4897d0f45b1f594bc429284c82efe49188
commit: 1e4a4c4897d0f45b1f594bc429284c82efe49188
branch: main
author: Dino Viehland <[email protected]>
committer: DinoV <[email protected]>
date: 2024-04-19T09:25:08-07:00
summary:

gh-117657: use relaxed loads for checking dict keys immortality (#118067)

Use relaxed load to check if dictkeys are immortal

files:
M Objects/dictobject.c
M Tools/tsan/suppressions_free_threading.txt

diff --git a/Objects/dictobject.c b/Objects/dictobject.c
index 58f34c32a87ea9..c3516dff973745 100644
--- a/Objects/dictobject.c
+++ b/Objects/dictobject.c
@@ -441,7 +441,7 @@ static void free_keys_object(PyDictKeysObject *keys, bool 
use_qsbr);
 static inline void
 dictkeys_incref(PyDictKeysObject *dk)
 {
-    if (dk->dk_refcnt == _Py_IMMORTAL_REFCNT) {
+    if (FT_ATOMIC_LOAD_SSIZE_RELAXED(dk->dk_refcnt) == _Py_IMMORTAL_REFCNT) {
         return;
     }
 #ifdef Py_REF_DEBUG
@@ -453,7 +453,7 @@ dictkeys_incref(PyDictKeysObject *dk)
 static inline void
 dictkeys_decref(PyInterpreterState *interp, PyDictKeysObject *dk, bool 
use_qsbr)
 {
-    if (dk->dk_refcnt == _Py_IMMORTAL_REFCNT) {
+    if (FT_ATOMIC_LOAD_SSIZE_RELAXED(dk->dk_refcnt) == _Py_IMMORTAL_REFCNT) {
         return;
     }
     assert(dk->dk_refcnt > 0);
diff --git a/Tools/tsan/suppressions_free_threading.txt 
b/Tools/tsan/suppressions_free_threading.txt
index 80191d6c2484e6..1408103ba80f96 100644
--- a/Tools/tsan/suppressions_free_threading.txt
+++ b/Tools/tsan/suppressions_free_threading.txt
@@ -29,8 +29,6 @@ race:_PyType_HasFeature
 race:assign_version_tag
 race:compare_unicode_unicode
 race:delitem_common
-race:dictkeys_decref
-race:dictkeys_incref
 race:dictresize
 race:gc_collect_main
 race:gc_restore_tid

_______________________________________________
Python-checkins mailing list -- [email protected]
To unsubscribe send an email to [email protected]
https://mail.python.org/mailman3/lists/python-checkins.python.org/
Member address: [email protected]

Reply via email to