From a025f27d94afe732be2e9e6f05b9007d04f983a8 Mon Sep 17 00:00:00 2001 From: Sam Gross Date: Thu, 6 Mar 2025 15:59:48 -0500 Subject: 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 --- Python/executor_cases.c.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'Python/executor_cases.c.h') diff --git a/Python/executor_cases.c.h b/Python/executor_cases.c.h index 29160b9f663..94f05c62089 100644 --- a/Python/executor_cases.c.h +++ b/Python/executor_cases.c.h @@ -1522,7 +1522,8 @@ } 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); -- cgit v1.2.3