diff options
author | Sam Gross <colesbury@gmail.com> | 2025-03-06 15:59:48 -0500 |
---|---|---|
committer | GitHub <noreply@github.com> | 2025-03-06 15:59:48 -0500 |
commit | a025f27d94afe732be2e9e6f05b9007d04f983a8 (patch) | |
tree | b6aa09f6d03597662245346c324823cde12323f7 /Python/executor_cases.c.h | |
parent | 6c6600f6831aec15b2acbd7a9bb9c275bd5f4a32 (diff) | |
download | cpython-a025f27d94afe732be2e9e6f05b9007d04f983a8.tar.gz cpython-a025f27d94afe732be2e9e6f05b9007d04f983a8.zip |
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>
Diffstat (limited to 'Python/executor_cases.c.h')
-rw-r--r-- | Python/executor_cases.c.h | 3 |
1 files changed, 2 insertions, 1 deletions
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); |