mirror of
https://github.com/python/cpython.git
synced 2025-08-04 00:48:58 +00:00
[3.13] gh-117657: Fix data races reported by TSAN in some set methods (GH-120914) (#121240)
Refactor the fast Unicode hash check into `_PyObject_HashFast` and use relaxed
atomic loads in the free-threaded build.
After this change, the TSAN doesn't report data races for this method.
(cherry picked from commit 294e724964
)
Co-authored-by: AN Long <aisk@users.noreply.github.com>
This commit is contained in:
parent
fc0b1cbdfe
commit
06fd745dd9
6 changed files with 81 additions and 121 deletions
|
@ -5069,15 +5069,10 @@ find_name_in_mro(PyTypeObject *type, PyObject *name, int *error)
|
|||
{
|
||||
ASSERT_TYPE_LOCK_HELD();
|
||||
|
||||
Py_hash_t hash;
|
||||
if (!PyUnicode_CheckExact(name) ||
|
||||
(hash = _PyASCIIObject_CAST(name)->hash) == -1)
|
||||
{
|
||||
hash = PyObject_Hash(name);
|
||||
if (hash == -1) {
|
||||
*error = -1;
|
||||
return NULL;
|
||||
}
|
||||
Py_hash_t hash = _PyObject_HashFast(name);
|
||||
if (hash == -1) {
|
||||
*error = -1;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/* Look in tp_dict of types in MRO */
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue