[pypy-commit] pypy default: Fix: if minor_collection() raises MemoryError, we used to be left with

arigo noreply at buildbot.pypy.org
Thu Mar 19 10:39:29 CET 2015


Author: Armin Rigo <arigo at tunes.org>
Branch: 
Changeset: r76465:15b2dab1fa08
Date: 2015-03-19 10:34 +0100
http://bitbucket.org/pypy/pypy/changeset/15b2dab1fa08/

Log:	Fix: if minor_collection() raises MemoryError, we used to be left
	with nursery_free==NULL

diff --git a/rpython/memory/gc/incminimark.py b/rpython/memory/gc/incminimark.py
--- a/rpython/memory/gc/incminimark.py
+++ b/rpython/memory/gc/incminimark.py
@@ -62,7 +62,7 @@
 from rpython.rlib.rarithmetic import ovfcheck, LONG_BIT, intmask, r_uint
 from rpython.rlib.rarithmetic import LONG_BIT_SHIFT
 from rpython.rlib.debug import ll_assert, debug_print, debug_start, debug_stop
-from rpython.rlib.objectmodel import specialize
+from rpython.rlib.objectmodel import specialize, we_are_translated
 
 #
 # Handles the objects in 2 generations:
@@ -695,7 +695,13 @@
 
         minor_collection_count = 0
         while True:
-            self.nursery_free = llmemory.NULL      # debug: don't use me
+            if not we_are_translated():
+                # debug: don't use 'nursery_free', but only if not translated;
+                # in real code we might get a MemoryError in minor_collection()
+                # and exit this function unexpectedly, but still catch the
+                # MemoryError somewhere and continue afterwards --- if we then
+                # see 'nursery_free == NULL', we segfault.
+                del self.nursery_free
 
             if self.nursery_barriers.non_empty():
                 size_gc_header = self.gcheaderbuilder.size_gc_header


More information about the pypy-commit mailing list