Skip to content

Commit c0571fc

Browse files
colesburysrinivasreddy
authored andcommitted
pythongh-127879: Fix data race in _PyFreeList_Push (python#127880)
Writes to the `ob_tid` field need to use atomics because it may be concurrently read by a non-locking dictionary, list, or structmember read.
1 parent f5c5bd6 commit c0571fc

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

Include/internal/pycore_freelist.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ static inline int
5151
_PyFreeList_Push(struct _Py_freelist *fl, void *obj, Py_ssize_t maxsize)
5252
{
5353
if (fl->size < maxsize && fl->size >= 0) {
54-
*(void **)obj = fl->freelist;
54+
FT_ATOMIC_STORE_PTR_RELAXED(*(void **)obj, fl->freelist);
5555
fl->freelist = obj;
5656
fl->size++;
5757
OBJECT_STAT_INC(to_freelist);

0 commit comments

Comments
 (0)