summaryrefslogtreecommitdiffstats
path: root/Python/bytecodes.c
diff options
context:
space:
mode:
authorSam Gross <colesbury@gmail.com>2025-03-06 20:59:48 (GMT)
committerGitHub <noreply@github.com>2025-03-06 20:59:48 (GMT)
commita025f27d94afe732be2e9e6f05b9007d04f983a8 (patch)
treeb6aa09f6d03597662245346c324823cde12323f7 /Python/bytecodes.c
parent6c6600f6831aec15b2acbd7a9bb9c275bd5f4a32 (diff)
downloadcpython-a025f27d94afe732be2e9e6f05b9007d04f983a8.zip
cpython-a025f27d94afe732be2e9e6f05b9007d04f983a8.tar.gz
cpython-a025f27d94afe732be2e9e6f05b9007d04f983a8.tar.bz2
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/bytecodes.c')
-rw-r--r--Python/bytecodes.c3
1 files changed, 2 insertions, 1 deletions
diff --git a/Python/bytecodes.c b/Python/bytecodes.c
index 24aa7bb..718c8f5 100644
--- a/Python/bytecodes.c
+++ b/Python/bytecodes.c
@@ -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);