summaryrefslogtreecommitdiffstats
path: root/Python
diff options
context:
space:
mode:
authorEric Snow <ericsnowcurrently@gmail.com>2023-08-16 10:03:05 (GMT)
committerGitHub <noreply@github.com>2023-08-16 10:03:05 (GMT)
commitaa9707dda9f8dcbe2ada8d8a7280f0f6a8229c59 (patch)
tree65b508c11793840d27e9f6b29c96496c740e75d5 /Python
parentbd2ef82a5010985abdeef2ca71bcbcc9a366993b (diff)
downloadcpython-aa9707dda9f8dcbe2ada8d8a7280f0f6a8229c59.zip
cpython-aa9707dda9f8dcbe2ada8d8a7280f0f6a8229c59.tar.gz
cpython-aa9707dda9f8dcbe2ada8d8a7280f0f6a8229c59.tar.bz2
[3.12] gh-107080: Fix Py_TRACE_REFS Crashes Under Isolated Subinterpreters (#107751)
* Unrevert "[3.12] gh-107080: Fix Py_TRACE_REFS Crashes Under Isolated Subinterpreters (gh-107567) (#107599)". This reverts commit 6e4eec760648a71e1cd8f8f551997b1823b4bb9f (gh-107648). * Initialize each interpreter's refchain properly. * Skip test_basic_multiple_interpreters_deleted_no_reset on tracerefs builds.
Diffstat (limited to 'Python')
-rw-r--r--Python/pylifecycle.c10
-rw-r--r--Python/pystate.c1
2 files changed, 7 insertions, 4 deletions
diff --git a/Python/pylifecycle.c b/Python/pylifecycle.c
index a67fa26..29771e0 100644
--- a/Python/pylifecycle.c
+++ b/Python/pylifecycle.c
@@ -1920,11 +1920,11 @@ Py_FinalizeEx(void)
}
if (dump_refs) {
- _Py_PrintReferences(stderr);
+ _Py_PrintReferences(tstate->interp, stderr);
}
if (dump_refs_fp != NULL) {
- _Py_PrintReferences(dump_refs_fp);
+ _Py_PrintReferences(tstate->interp, dump_refs_fp);
}
#endif /* Py_TRACE_REFS */
@@ -1960,11 +1960,11 @@ Py_FinalizeEx(void)
*/
if (dump_refs) {
- _Py_PrintReferenceAddresses(stderr);
+ _Py_PrintReferenceAddresses(tstate->interp, stderr);
}
if (dump_refs_fp != NULL) {
- _Py_PrintReferenceAddresses(dump_refs_fp);
+ _Py_PrintReferenceAddresses(tstate->interp, dump_refs_fp);
fclose(dump_refs_fp);
}
#endif /* Py_TRACE_REFS */
@@ -2074,6 +2074,8 @@ new_interpreter(PyThreadState **tstate_p, const PyInterpreterConfig *config)
}
has_gil = 1;
+ /* No objects have been created yet. */
+
status = pycore_interp_init(tstate);
if (_PyStatus_EXCEPTION(status)) {
goto error;
diff --git a/Python/pystate.c b/Python/pystate.c
index 8097124..2ee16e3 100644
--- a/Python/pystate.c
+++ b/Python/pystate.c
@@ -673,6 +673,7 @@ init_interpreter(PyInterpreterState *interp,
_obmalloc_pools_INIT(interp->obmalloc.pools);
memcpy(&interp->obmalloc.pools.used, temp, sizeof(temp));
}
+ _PyObject_InitState(interp);
_PyEval_InitState(interp, pending_lock);
_PyGC_InitState(&interp->gc);