]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
gh-118074: Immortal executors are not GC-able (#118182)
authorGuido van Rossum <guido@python.org>
Tue, 23 Apr 2024 20:38:23 +0000 (13:38 -0700)
committerGitHub <noreply@github.com>
Tue, 23 Apr 2024 20:38:23 +0000 (13:38 -0700)
Better version of gh-118117.
Just check for immortality instead of an address range check.

Python/optimizer.c

index 5863336c0d9ecfeaf9b5a6121283b65a48e3e9ca..0017965c32f290b1e4532b57bac8b727a4c3a891 100644 (file)
@@ -397,10 +397,7 @@ executor_traverse(PyObject *o, visitproc visit, void *arg)
 static int
 executor_is_gc(PyObject *o)
 {
-    if ((PyObject *)&COLD_EXITS[0] <= o && o < (PyObject *)&COLD_EXITS[COLD_EXIT_COUNT]) {
-        return 0;
-    }
-    return 1;
+    return !_Py_IsImmortal(o);
 }
 
 PyTypeObject _PyUOpExecutor_Type = {