https://github.com/python/cpython/commit/76f6b5e64a8b6ea5a88606f3665cd9f52c2c2798
commit: 76f6b5e64a8b6ea5a88606f3665cd9f52c2c2798
branch: main
author: Kumar Aditya <[email protected]>
committer: kumaraditya303 <[email protected]>
date: 2025-04-02T20:01:05+05:30
summary:
gh-132013: use relaxed atomics in hash of frozenset (#132014)
Use relaxed atomics in hash of `frozenset` to fix TSAN warning.
files:
M Objects/setobject.c
diff --git a/Objects/setobject.c b/Objects/setobject.c
index 5ad83c3f1633b9..f65d458f7924c3 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;
}
_______________________________________________
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]