Skip to content
Closed
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
Next Next commit
gh-129069: use atomic read in _Py_SIZE_impl()
part of TSAN-0013 in gh-153852
  • Loading branch information
xxyzz committed Jul 23, 2026
commit cb9567a4a3085ed6a705a381cfb53cfc20870636
4 changes: 0 additions & 4 deletions Include/cpython/listobject.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,7 @@ typedef struct {

static inline Py_ssize_t PyList_GET_SIZE(PyObject *op) {
PyListObject *list = _PyList_CAST(op);
#ifdef Py_GIL_DISABLED
return _Py_atomic_load_ssize_relaxed(&(_PyVarObject_CAST(list)->ob_size));
#else
return Py_SIZE(list);
#endif
}
#define PyList_GET_SIZE(op) PyList_GET_SIZE(_PyObject_CAST(op))

Expand Down
6 changes: 5 additions & 1 deletion Include/object.h
Original file line number Diff line number Diff line change
Expand Up @@ -240,7 +240,11 @@ _Py_SIZE_impl(PyObject *ob)
{
assert(Py_TYPE(ob) != &PyLong_Type);
assert(Py_TYPE(ob) != &PyBool_Type);
return _PyVarObject_CAST(ob)->ob_size;
#ifdef Py_GIL_DISABLED
return _Py_atomic_load_ssize_relaxed(&(_PyVarObject_CAST(ob)->ob_size));
#else
return _PyVarObject_CAST(ob)->ob_size;
#endif
}

static inline int
Expand Down