]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
bpo-40533: Disable GC in subinterpreters (GH-19961)
authorVictor Stinner <vstinner@python.org>
Wed, 6 May 2020 16:25:06 +0000 (18:25 +0200)
committerGitHub <noreply@github.com>
Wed, 6 May 2020 16:25:06 +0000 (18:25 +0200)
When Python is built with experimental isolated interpreters, a
garbage collection now does nothing in an isolated interpreter.

Temporary workaround until subinterpreters stop sharing Python
objects.

Modules/gcmodule.c

index 56dcb101e0005e55b0f1ca132b218d1c9f8c2cc8..a44752b1cc4da7ff5346e2899a50d7fc528e3e6e 100644 (file)
@@ -1181,6 +1181,14 @@ collect(PyThreadState *tstate, int generation,
     _PyTime_t t1 = 0;   /* initialize to prevent a compiler warning */
     GCState *gcstate = &tstate->interp->gc;
 
+#ifdef EXPERIMENTAL_ISOLATED_SUBINTERPRETERS
+    if (tstate->interp->config._isolated_interpreter) {
+        // bpo-40533: The garbage collector must not be run on parallel on
+        // Python objects shared by multiple interpreters.
+        return 0;
+    }
+#endif
+
     if (gcstate->debug & DEBUG_STATS) {
         PySys_WriteStderr("gc: collecting generation %d...\n", generation);
         show_stats_each_generations(gcstate);