Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 15 additions & 1 deletion Lib/test/test_free_threading/test_list.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import unittest

from threading import Thread
from threading import Thread, Barrier
from unittest import TestCase

from test.support import threading_helper
Expand Down Expand Up @@ -71,6 +71,20 @@ def reader_func():
for reader in readers:
reader.join()

def test_store_list_int(self):
def copy_back_and_forth(b, l):
b.wait()
for _ in range(100):
l[0] = l[1]
l[1] = l[0]

l = [0, 1]
barrier = Barrier(NTHREAD)
threads = [Thread(target=copy_back_and_forth, args=(barrier, l))
for _ in range(NTHREAD)]
with threading_helper.start_threads(threads):
pass


if __name__ == "__main__":
unittest.main()
3 changes: 2 additions & 1 deletion Python/bytecodes.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
3 changes: 2 additions & 1 deletion Python/executor_cases.c.h

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion Python/generated_cases.c.h

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading