summaryrefslogtreecommitdiffstats
path: root/Include/internal/pycore_runtime_init.h
diff options
context:
space:
mode:
authorEric Snow <ericsnowcurrently@gmail.com>2023-08-03 19:51:08 (GMT)
committerGitHub <noreply@github.com>2023-08-03 19:51:08 (GMT)
commit58ef74186795c56e3ec86e8c8f351a1d7826638a (patch)
tree592cedc60a6828d0185d6dc84319cbcc97564e8b /Include/internal/pycore_runtime_init.h
parent14fbd4e6b16dcbcbff448b047f7e2faa27bbedba (diff)
downloadcpython-58ef74186795c56e3ec86e8c8f351a1d7826638a.zip
cpython-58ef74186795c56e3ec86e8c8f351a1d7826638a.tar.gz
cpython-58ef74186795c56e3ec86e8c8f351a1d7826638a.tar.bz2
gh-107080: Fix Py_TRACE_REFS Crashes Under Isolated Subinterpreters (gh-107567)
The linked list of objects was a global variable, which broke isolation between interpreters, causing crashes. To solve this, we've moved the linked list to each interpreter.
Diffstat (limited to 'Include/internal/pycore_runtime_init.h')
-rw-r--r--Include/internal/pycore_runtime_init.h11
1 files changed, 11 insertions, 0 deletions
diff --git a/Include/internal/pycore_runtime_init.h b/Include/internal/pycore_runtime_init.h
index dcfceef..e89d368 100644
--- a/Include/internal/pycore_runtime_init.h
+++ b/Include/internal/pycore_runtime_init.h
@@ -157,6 +157,7 @@ extern PyTypeObject _PyExc_MemoryError;
{ .threshold = 10, }, \
}, \
}, \
+ .object_state = _py_object_state_INIT(INTERP), \
.dtoa = _dtoa_state_INIT(&(INTERP)), \
.dict_state = _dict_state_INIT, \
.func_state = { \
@@ -186,6 +187,16 @@ extern PyTypeObject _PyExc_MemoryError;
.context_ver = 1, \
}
+#ifdef Py_TRACE_REFS
+# define _py_object_state_INIT(INTERP) \
+ { \
+ .refchain = {&INTERP.object_state.refchain, &INTERP.object_state.refchain}, \
+ }
+#else
+# define _py_object_state_INIT(INTERP) \
+ { 0 }
+#endif
+
// global objects