While reviewing #130096, I checked the thread safety of list object and there at some places we are missing atomic stores of index.
Specifically the following:
|
else if (index > PyList_GET_SIZE(it->it_seq)) |
|
index = PyList_GET_SIZE(it->it_seq); /* iterator exhausted */ |
|
it->it_index = index; |
|
} |
|
else if (index > PyList_GET_SIZE(it->it_seq) - 1) |
|
index = PyList_GET_SIZE(it->it_seq) - 1; |
|
it->it_index = index; |
|
} |
They should use atomic relaxed stores.
Linked PRs
While reviewing #130096, I checked the thread safety of list object and there at some places we are missing atomic stores of index.
Specifically the following:
cpython/Objects/listobject.c
Lines 3994 to 3997 in 97d0011
cpython/Objects/listobject.c
Lines 4146 to 4149 in 97d0011
They should use atomic relaxed stores.
Linked PRs