Skip to content

Commit 1e4a4c4

Browse files
authored
gh-117657: use relaxed loads for checking dict keys immortality (#118067)
Use relaxed load to check if dictkeys are immortal
1 parent 8d4a244 commit 1e4a4c4

File tree

2 files changed

+2
-4
lines changed

2 files changed

+2
-4
lines changed

Objects/dictobject.c

+2-2
Original file line numberDiff line numberDiff line change
@@ -441,7 +441,7 @@ static void free_keys_object(PyDictKeysObject *keys, bool use_qsbr);
441441
static inline void
442442
dictkeys_incref(PyDictKeysObject *dk)
443443
{
444-
if (dk->dk_refcnt == _Py_IMMORTAL_REFCNT) {
444+
if (FT_ATOMIC_LOAD_SSIZE_RELAXED(dk->dk_refcnt) == _Py_IMMORTAL_REFCNT) {
445445
return;
446446
}
447447
#ifdef Py_REF_DEBUG
@@ -453,7 +453,7 @@ dictkeys_incref(PyDictKeysObject *dk)
453453
static inline void
454454
dictkeys_decref(PyInterpreterState *interp, PyDictKeysObject *dk, bool use_qsbr)
455455
{
456-
if (dk->dk_refcnt == _Py_IMMORTAL_REFCNT) {
456+
if (FT_ATOMIC_LOAD_SSIZE_RELAXED(dk->dk_refcnt) == _Py_IMMORTAL_REFCNT) {
457457
return;
458458
}
459459
assert(dk->dk_refcnt > 0);

Tools/tsan/suppressions_free_threading.txt

-2
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,6 @@ race:_PyType_HasFeature
2929
race:assign_version_tag
3030
race:compare_unicode_unicode
3131
race:delitem_common
32-
race:dictkeys_decref
33-
race:dictkeys_incref
3432
race:dictresize
3533
race:gc_collect_main
3634
race:gc_restore_tid

0 commit comments

Comments
 (0)