#endif
}
+static void
+ensure_shared_on_resize(PyListObject *self)
+{
+#ifdef Py_GIL_DISABLED
+ // Ensure that the list array is freed using QSBR if we are not the
+ // owning thread.
+ if (!_Py_IsOwnedByCurrentThread((PyObject *)self) &&
+ !_PyObject_GC_IS_SHARED(self))
+ {
+ _PyObject_GC_SET_SHARED(self);
+ }
+#endif
+}
+
/* Ensure ob_item has room for at least newsize elements, and set
* ob_size to newsize. If newsize > ob_size on entry, the content
* of the new slots at exit is undefined heap trash; it's the caller's
if (newsize == 0)
new_allocated = 0;
+ ensure_shared_on_resize(self);
+
#ifdef Py_GIL_DISABLED
_PyListArray *array = list_allocate_array(new_allocated);
if (array == NULL) {
Py_XDECREF(items[i]);
}
#ifdef Py_GIL_DISABLED
+ if (is_resize) {
+ ensure_shared_on_resize(a);
+ }
bool use_qsbr = is_resize && _PyObject_GC_IS_SHARED(a);
#else
bool use_qsbr = false;
Py_XDECREF(final_ob_item[i]);
}
#ifdef Py_GIL_DISABLED
+ ensure_shared_on_resize(self);
bool use_qsbr = _PyObject_GC_IS_SHARED(self);
#else
bool use_qsbr = false;