https://github.com/python/cpython/commit/f8dcb8200626a1a06c4a26d8129257f42658a9ff
commit: f8dcb8200626a1a06c4a26d8129257f42658a9ff
branch: main
author: Sam Gross <[email protected]>
committer: colesbury <[email protected]>
date: 2024-12-12T12:59:13-05:00
summary:
gh-127879: Fix data race in `_PyFreeList_Push` (#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.
files:
M Include/internal/pycore_freelist.h
diff --git a/Include/internal/pycore_freelist.h
b/Include/internal/pycore_freelist.h
index da2d7bf6ae1393..84a5ab30f3eeea 100644
--- a/Include/internal/pycore_freelist.h
+++ b/Include/internal/pycore_freelist.h
@@ -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);
_______________________________________________
Python-checkins mailing list -- [email protected]
To unsubscribe send an email to [email protected]
https://mail.python.org/mailman3/lists/python-checkins.python.org/
Member address: [email protected]