diff --git a/Misc/NEWS.d/next/Core and Builtins/2017-10-12-23-45-54.bpo-30156.dZ3kZk.rst b/Misc/NEWS.d/next/Core and Builtins/2017-10-12-23-45-54.bpo-30156.dZ3kZk.rst new file mode 100644 index 00000000000000..c1c50e33d05335 --- /dev/null +++ b/Misc/NEWS.d/next/Core and Builtins/2017-10-12-23-45-54.bpo-30156.dZ3kZk.rst @@ -0,0 +1 @@ +Fixed a crash in debug build when PYTHONDUMPREFS is set. diff --git a/Objects/descrobject.c b/Objects/descrobject.c index 5dc27ef67278a4..5903912aba2211 100644 --- a/Objects/descrobject.c +++ b/Objects/descrobject.c @@ -1379,12 +1379,15 @@ property_descr_get(PyObject *self, PyObject *obj, PyObject *type) return NULL; } args = cached_args; - cached_args = NULL; if (!args) { args = PyTuple_New(1); if (!args) return NULL; - _PyObject_GC_UNTRACK(args); + } + else { + cached_args = NULL; + assert(Py_REFCNT(args) == 1); + Py_SIZE(args) = 1; } Py_INCREF(obj); PyTuple_SET_ITEM(args, 0, obj); @@ -1392,12 +1395,12 @@ property_descr_get(PyObject *self, PyObject *obj, PyObject *type) if (cached_args == NULL && Py_REFCNT(args) == 1) { assert(PyTuple_GET_SIZE(args) == 1); assert(PyTuple_GET_ITEM(args, 0) == obj); + Py_SIZE(args) = 0; cached_args = args; Py_DECREF(obj); } else { assert(Py_REFCNT(args) >= 1); - _PyObject_GC_TRACK(args); Py_DECREF(args); } return ret;