Skip to content

Commit

Permalink
gh-127879: Fix data race in _PyFreeList_Push (#127880)
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
colesbury authored Dec 12, 2024
1 parent 7146f18 commit f8dcb82
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion Include/internal/pycore_freelist.h
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ static inline int
_PyFreeList_Push(struct _Py_freelist *fl, void *obj, Py_ssize_t maxsize)
{
if (fl->size < maxsize && fl->size >= 0) {
*(void **)obj = fl->freelist;
FT_ATOMIC_STORE_PTR_RELAXED(*(void **)obj, fl->freelist);
fl->freelist = obj;
fl->size++;
OBJECT_STAT_INC(to_freelist);
Expand Down

0 comments on commit f8dcb82

Please sign in to comment.