gh-117657: Fix TSAN list set failure (#118260)

* Fix TSAN list set failure

* Relaxed atomic is sufficient, add targetted test

* More list

* Remove atomic assign in list

* Fixup white space
This commit is contained in:
Dino Viehland 2024-05-02 13:03:05 -07:00 committed by GitHub
parent 8ed5466795
commit 1e67b9207c
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 90 additions and 3 deletions

View file

@ -28,7 +28,11 @@ _PyList_AppendTakeRef(PyListObject *self, PyObject *newitem)
Py_ssize_t allocated = self->allocated;
assert((size_t)len + 1 < PY_SSIZE_T_MAX);
if (allocated > len) {
#ifdef Py_GIL_DISABLED
_Py_atomic_store_ptr_release(&self->ob_item[len], newitem);
#else
PyList_SET_ITEM(self, len, newitem);
#endif
Py_SET_SIZE(self, len + 1);
return 0;
}