gh-133980: use atomic store in PyObject_GenericSetDict (#133988)

This commit is contained in:
Kumar Aditya 2025-05-20 21:11:47 +05:30 committed by GitHub
parent 317c496223
commit ec39fd2c20
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 23 additions and 1 deletions

View file

@ -1931,7 +1931,13 @@ PyObject_GenericSetDict(PyObject *obj, PyObject *value, void *context)
return -1;
}
Py_BEGIN_CRITICAL_SECTION(obj);
Py_XSETREF(*dictptr, Py_NewRef(value));
PyObject *olddict = *dictptr;
FT_ATOMIC_STORE_PTR_RELEASE(*dictptr, Py_NewRef(value));
#ifdef Py_GIL_DISABLED
_PyObject_XDecRefDelayed(olddict);
#else
Py_XDECREF(olddict);
#endif
Py_END_CRITICAL_SECTION();
return 0;
}