mirror of
https://github.com/python/cpython.git
synced 2025-08-04 17:08:35 +00:00
gh-117657: Fix data race in _Py_IsImmortal
(#118261)
The load of `ob_ref_local races with stores. Using a relaxed load is sufficient; stores to the field are relaxed.
This commit is contained in:
parent
fb7f79b4da
commit
f14e9f9154
2 changed files with 2 additions and 2 deletions
|
@ -349,7 +349,8 @@ static inline Py_ssize_t Py_SIZE(PyObject *ob) {
|
|||
static inline Py_ALWAYS_INLINE int _Py_IsImmortal(PyObject *op)
|
||||
{
|
||||
#if defined(Py_GIL_DISABLED)
|
||||
return (op->ob_ref_local == _Py_IMMORTAL_REFCNT_LOCAL);
|
||||
return (_Py_atomic_load_uint32_relaxed(&op->ob_ref_local) ==
|
||||
_Py_IMMORTAL_REFCNT_LOCAL);
|
||||
#elif SIZEOF_VOID_P > 4
|
||||
return (_Py_CAST(PY_INT32_T, op->ob_refcnt) < 0);
|
||||
#else
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue