From: Kumar Aditya Date: Wed, 2 Apr 2025 14:31:05 +0000 (+0530) Subject: gh-132013: use relaxed atomics in hash of frozenset (#132014) X-Git-Tag: v3.14.0a7~99 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=76f6b5e64a8b6ea5a88606f3665cd9f52c2c2798;p=thirdparty%2FPython%2Fcpython.git gh-132013: use relaxed atomics in hash of frozenset (#132014) Use relaxed atomics in hash of `frozenset` to fix TSAN warning. --- diff --git a/Objects/setobject.c b/Objects/setobject.c index 5ad83c3f1633..f65d458f7924 100644 --- a/Objects/setobject.c +++ b/Objects/setobject.c @@ -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; }