8000 gh-132013: use relaxed atomics in hash of frozenset (#132014) · python/cpython@76f6b5e · GitHub
[go: up one dir, main page]

Skip to content

Commit 76f6b5e

Browse files
gh-132013: use relaxed atomics in hash of frozenset (#132014)
Use relaxed atomics in hash of `frozenset` to fix TSAN warning.
1 parent b0f77c4 commit 76f6b5e

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

Objects/setobject.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -793,12 +793,12 @@ frozenset_hash(PyObject *self)
793793
PySetObject *so = _PySet_CAST(self);
794794
Py_uhash_t hash;
795795

796-
if (so->hash != -1) {
797-
return so->hash;
796+
if (FT_ATOMIC_LOAD_SSIZE_RELAXED(so->hash) != -1) {
797+
return FT_ATOMIC_LOAD_SSIZE_RELAXED(so->hash);
798798
}
799799

800800
hash = frozenset_hash_impl(self);
801-
so->hash = hash;
801+
FT_ATOMIC_STORE_SSIZE_RELAXED(so->hash, hash);
802802
return hash;
803803
}
804804

0 commit comments

Comments
 (0)
0