diff --git a/Include/internal/pycore_cell.h b/Include/internal/pycore_cell.h index 1af8d0972ea07bb..d2f82e45ebaf801 100644 --- a/Include/internal/pycore_cell.h +++ b/Include/internal/pycore_cell.h @@ -19,8 +19,8 @@ PyCell_SwapTakeRef(PyCellObject *cell, PyObject *value) { PyObject *old_value; Py_BEGIN_CRITICAL_SECTION(cell); - old_value = cell->ob_ref; - cell->ob_ref = value; + FT_ATOMIC_STORE_PTR_RELAXED(old_value, cell->ob_ref); + FT_ATOMIC_STORE_PTR_RELAXED(cell->ob_ref, value); Py_END_CRITICAL_SECTION(); return old_value; }