gh-132013: use relaxed atomics in hash of frozenset (#132014)

Use relaxed atomics in hash of `frozenset` to fix TSAN warning.
This commit is contained in:
Kumar Aditya 2025-04-02 20:01:05 +05:30 committed by GitHub
parent b0f77c4d25
commit 76f6b5e64a
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -793,12 +793,12 @@ frozenset_hash(PyObject *self)
PySetObject *so = _PySet_CAST(self);
Py_uhash_t hash;
if (so->hash != -1) {
return so->hash;
if (FT_ATOMIC_LOAD_SSIZE_RELAXED(so->hash) != -1) {
return FT_ATOMIC_LOAD_SSIZE_RELAXED(so->hash);
}
hash = frozenset_hash_impl(self);
so->hash = hash;
FT_ATOMIC_STORE_SSIZE_RELAXED(so->hash, hash);
return hash;
}