Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Restore the original guard for list_get_item_ref's fast path, since it's
actually correct and the real problem was an incorrect assert. The fast path
still contains notionally unsafe uses of memcpy/memmove, so add
list_get_item_ref back to the TSan suppressions file.
  • Loading branch information
Yhg1s committed Jan 9, 2025
commit 661dc7bf4448fcb1ec6b437bc6559fef608fcab7
6 changes: 3 additions & 3 deletions Objects/listobject.c
Original file line number Diff line number Diff line change
Expand Up @@ -344,7 +344,7 @@ list_item_impl(PyListObject *self, Py_ssize_t idx)
static inline PyObject*
list_get_item_ref(PyListObject *op, Py_ssize_t i)
{
if (!_Py_IsOwnedByCurrentThread((PyObject *)op)) {
if (!_Py_IsOwnedByCurrentThread((PyObject *)op) && !_PyObject_GC_IS_SHARED(op)) {
return list_item_impl(op, i);
}
// Need atomic operation for the getting size.
Expand All @@ -357,7 +357,7 @@ list_get_item_ref(PyListObject *op, Py_ssize_t i)
return NULL;
}
Py_ssize_t cap = list_capacity(ob_item);
assert(cap != -1 && cap >= size);
assert(cap != -1);
if (!valid_index(i, cap)) {
return NULL;
}
Expand Down Expand Up @@ -937,7 +937,7 @@ list_ass_slice_lock_held(PyListObject *a, Py_ssize_t ilow, Py_ssize_t ihigh, PyO
}
for (k = 0; k < n; k++, ilow++) {
PyObject *w = vitem[k];
item[ilow] = Py_XNewRef(w);
FT_ATOMIC_STORE_PTR_RELAXED(item[ilow], Py_XNewRef(w));
Comment thread
Yhg1s marked this conversation as resolved.
Outdated
}
for (k = norig - 1; k >= 0; --k)
Py_XDECREF(recycle[k]);
Expand Down
1 change: 1 addition & 0 deletions Tools/tsan/suppressions_free_threading.txt
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ race_top:add_threadstate
race_top:dump_traceback
race_top:fatal_error
race_top:_multiprocessing_SemLock_release_impl
race_top:list_get_item_ref
race_top:_PyFrame_GetCode
race_top:_PyFrame_Initialize
race_top:PyInterpreterState_ThreadHead
Expand Down