gh-130920: Fix data race in STORE_SUBSCR_LIST_INT (#130923)
The write of the item to the list needs to use an atomic operation in the free threading build. Co-authored-by: Tomasz Pytel <tompytel@gmail.com>
This commit is contained in:
@@ -1015,7 +1015,8 @@ dummy_func(
|
||||
STAT_INC(STORE_SUBSCR, hit);
|
||||
|
||||
PyObject *old_value = PyList_GET_ITEM(list, index);
|
||||
PyList_SET_ITEM(list, index, PyStackRef_AsPyObjectSteal(value));
|
||||
FT_ATOMIC_STORE_PTR_RELEASE(_PyList_ITEMS(list)[index],
|
||||
PyStackRef_AsPyObjectSteal(value));
|
||||
assert(old_value != NULL);
|
||||
UNLOCK_OBJECT(list); // unlock before decrefs!
|
||||
PyStackRef_CLOSE_SPECIALIZED(sub_st, _PyLong_ExactDealloc);
|
||||
|
||||
Reference in New Issue
Block a user