summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGuido van Rossum <guido@python.org>2024-04-22 23:20:39 (GMT)
committerGitHub <noreply@github.com>2024-04-22 23:20:39 (GMT)
commit1b85b3424c081835406592868123fe898ee029ad (patch)
treeb23f4e7a10c219ba79e4615d01c7dc65f3cd2491
parentfc21c7f7a731d64f7e4f0e82469f78fa9c104bbd (diff)
downloadcpython-1b85b3424c081835406592868123fe898ee029ad.zip
cpython-1b85b3424c081835406592868123fe898ee029ad.tar.gz
cpython-1b85b3424c081835406592868123fe898ee029ad.tar.bz2
GH-118074: Executors in the COLD_EXITS array are not GC'able (#118117)
-rw-r--r--Misc/NEWS.d/next/Core and Builtins/2024-04-22-08-34-28.gh-issue-118074.5_JnIa.rst2
-rw-r--r--Python/optimizer.c10
2 files changed, 12 insertions, 0 deletions
diff --git a/Misc/NEWS.d/next/Core and Builtins/2024-04-22-08-34-28.gh-issue-118074.5_JnIa.rst b/Misc/NEWS.d/next/Core and Builtins/2024-04-22-08-34-28.gh-issue-118074.5_JnIa.rst
new file mode 100644
index 0000000..69d29bc
--- /dev/null
+++ b/Misc/NEWS.d/next/Core and Builtins/2024-04-22-08-34-28.gh-issue-118074.5_JnIa.rst
@@ -0,0 +1,2 @@
+Make sure that the Executor objects in the COLD_EXITS array aren't assumed
+to be GC-able (which would access bytes outside the object).
diff --git a/Python/optimizer.c b/Python/optimizer.c
index bb537c9..5863336 100644
--- a/Python/optimizer.c
+++ b/Python/optimizer.c
@@ -394,6 +394,15 @@ executor_traverse(PyObject *o, visitproc visit, void *arg)
return 0;
}
+static int
+executor_is_gc(PyObject *o)
+{
+ if ((PyObject *)&COLD_EXITS[0] <= o && o < (PyObject *)&COLD_EXITS[COLD_EXIT_COUNT]) {
+ return 0;
+ }
+ return 1;
+}
+
PyTypeObject _PyUOpExecutor_Type = {
PyVarObject_HEAD_INIT(&PyType_Type, 0)
.tp_name = "uop_executor",
@@ -405,6 +414,7 @@ PyTypeObject _PyUOpExecutor_Type = {
.tp_methods = executor_methods,
.tp_traverse = executor_traverse,
.tp_clear = executor_clear,
+ .tp_is_gc = executor_is_gc,
};
/* TO DO -- Generate these tables */