summaryrefslogtreecommitdiffstats
path: root/Objects
diff options
context:
space:
mode:
authorEric Snow <ericsnowcurrently@gmail.com>2023-08-07 19:14:56 (GMT)
committerGitHub <noreply@github.com>2023-08-07 19:14:56 (GMT)
commit430632d6f710c99879c5d1736f3b40ea09b11c4d (patch)
tree5c170b5a94186d7703e353837fbfcc1b2b8ec47b /Objects
parent16c9415fba4972743f1944ebc44946e475e68bc4 (diff)
downloadcpython-430632d6f710c99879c5d1736f3b40ea09b11c4d.zip
cpython-430632d6f710c99879c5d1736f3b40ea09b11c4d.tar.gz
cpython-430632d6f710c99879c5d1736f3b40ea09b11c4d.tar.bz2
gh-107630: Initialize Each Interpreter's refchain Properly (gh-107733)
This finishes fixing the crashes in Py_TRACE_REFS builds. We missed this part in gh-107567.
Diffstat (limited to 'Objects')
-rw-r--r--Objects/object.c22
1 files changed, 21 insertions, 1 deletions
diff --git a/Objects/object.c b/Objects/object.c
index c4413a0..d1154eb 100644
--- a/Objects/object.c
+++ b/Objects/object.c
@@ -162,6 +162,14 @@ _PyDebug_PrintTotalRefs(void) {
#define REFCHAIN(interp) &interp->object_state.refchain
+static inline void
+init_refchain(PyInterpreterState *interp)
+{
+ PyObject *refchain = REFCHAIN(interp);
+ refchain->_ob_prev = refchain;
+ refchain->_ob_next = refchain;
+}
+
/* Insert op at the front of the list of all objects. If force is true,
* op is added even if _ob_prev and _ob_next are non-NULL already. If
* force is false amd _ob_prev or _ob_next are non-NULL, do nothing.
@@ -2019,6 +2027,18 @@ PyObject _Py_NotImplementedStruct = {
&_PyNotImplemented_Type
};
+
+void
+_PyObject_InitState(PyInterpreterState *interp)
+{
+#ifdef Py_TRACE_REFS
+ if (!_Py_IsMainInterpreter(interp)) {
+ init_refchain(interp);
+ }
+#endif
+}
+
+
extern PyTypeObject _Py_GenericAliasIterType;
extern PyTypeObject _PyMemoryIter_Type;
extern PyTypeObject _PyLineIterator;
@@ -2326,7 +2346,7 @@ _Py_GetObjects(PyObject *self, PyObject *args)
#undef REFCHAIN
-#endif
+#endif /* Py_TRACE_REFS */
/* Hack to force loading of abstract.o */