[pypy-svn] r61511 - in pypy/trunk/pypy: interpreter rpython/memory/gctransform rpython/memory/test

arigo at codespeak.net arigo at codespeak.net
Mon Feb 2 10:38:54 CET 2009


Author: arigo
Date: Mon Feb  2 10:38:52 2009
New Revision: 61511

Modified:
   pypy/trunk/pypy/interpreter/generator.py
   pypy/trunk/pypy/rpython/memory/gctransform/framework.py
   pypy/trunk/pypy/rpython/memory/test/snippet.py
Log:
Fix.  As usual around here, it's a 3-lines fix with a pages-long test...


Modified: pypy/trunk/pypy/interpreter/generator.py
==============================================================================
--- pypy/trunk/pypy/interpreter/generator.py	(original)
+++ pypy/trunk/pypy/interpreter/generator.py	Mon Feb  2 10:38:52 2009
@@ -124,8 +124,6 @@
         """
         self.descr_close()
 
-##     # it seems there is a bug in the hybrid gc, if we add a __del__ it
-##     # segfaults. With mark&sweep it works correctly
-##     def __del__(self):
-##         if not self.frame.frame_finished_execution:
-##             self._enqueue_for_destruction(self.space)
+    def __del__(self):
+        if not self.frame.frame_finished_execution:
+            self._enqueue_for_destruction(self.space)

Modified: pypy/trunk/pypy/rpython/memory/gctransform/framework.py
==============================================================================
--- pypy/trunk/pypy/rpython/memory/gctransform/framework.py	(original)
+++ pypy/trunk/pypy/rpython/memory/gctransform/framework.py	Mon Feb  2 10:38:52 2009
@@ -87,6 +87,9 @@
                 mallocop.result is checkop.args[0] and
                 block.exitswitch is checkop.result):
             continue
+        rtti = get_rtti(mallocop.args[0].value)
+        if rtti is not None and hasattr(rtti._obj, 'destructor_funcptr'):
+            continue
         exits = [exit for exit in block.exits if exit.llexitcase]
         if len(exits) != 1:
             continue

Modified: pypy/trunk/pypy/rpython/memory/test/snippet.py
==============================================================================
--- pypy/trunk/pypy/rpython/memory/test/snippet.py	(original)
+++ pypy/trunk/pypy/rpython/memory/test/snippet.py	Mon Feb  2 10:38:52 2009
@@ -125,3 +125,36 @@
             print summary
             print msg
             py.test.fail(msg)
+
+
+    def test_from_objwithfinalizer_to_youngobj(self):
+        import gc
+        if self.large_tests_ok:
+            MAX = 500000
+        else:
+            MAX = 150
+
+        class B:
+            count = 0
+        class A:
+            def __del__(self):
+                self.b.count += 1
+        def g():
+            b = B()
+            a = A()
+            a.b = b
+            i = 0
+            lst = [None]
+            while i < MAX:
+                lst[0] = str(i)
+                i += 1
+            return a.b, lst
+        g._dont_inline_ = True
+
+        def f():
+            b, lst = g()
+            gc.collect()
+            return str(b.count)
+
+        res = self.run(f)
+        assert res == '1'



More information about the Pypy-commit mailing list