bpo-40533: Make PyObject.ob_refcnt atomic in subinterpreters
When Python is built with experimental isolated interpreters, declare PyObject.ob_refcnt and _dictkeysobject.dk_refcnt as atomic variables. Temporary workaround until subinterpreters stop sharing Python objects.
This commit is contained in:
parent
2668a9a5aa
commit
b45420da66
|
@ -104,7 +104,14 @@ typedef struct _typeobject PyTypeObject;
|
|||
*/
|
||||
typedef struct _object {
|
||||
_PyObject_HEAD_EXTRA
|
||||
#ifdef EXPERIMENTAL_ISOLATED_SUBINTERPRETERS
|
||||
/* bpo-40533: Use an atomic variable for PyObject.ob_refcnt, to ensure that
|
||||
Py_INCREF() and Py_DECREF() are safe when called in parallel, until
|
||||
subinterpreters stop sharing Python objects. */
|
||||
_Atomic Py_ssize_t ob_refcnt;
|
||||
#else
|
||||
Py_ssize_t ob_refcnt;
|
||||
#endif
|
||||
PyTypeObject *ob_type;
|
||||
} PyObject;
|
||||
|
||||
|
|
|
@ -20,7 +20,13 @@ typedef Py_ssize_t (*dict_lookup_func)
|
|||
|
||||
/* See dictobject.c for actual layout of DictKeysObject */
|
||||
struct _dictkeysobject {
|
||||
#ifdef EXPERIMENTAL_ISOLATED_SUBINTERPRETERS
|
||||
/* bpo-40533: Use an atomic variables until subinterpreters stop sharing
|
||||
Python dictionaries. */
|
||||
_Atomic Py_ssize_t dk_refcnt;
|
||||
#else
|
||||
Py_ssize_t dk_refcnt;
|
||||
#endif
|
||||
|
||||
/* Size of the hash table (dk_indices). It must be a power of 2. */
|
||||
Py_ssize_t dk_size;
|
||||
|
|
Loading…
Reference in New Issue