[pypy-commit] pypy gc-incminimark-pinning: failing test: malloc object of type A, pin it, do GC collect and try to malloc object of type B.

groggi noreply at buildbot.pypy.org
Tue Aug 19 15:14:49 CEST 2014


Author: Gregor Wegberg <code at gregorwegberg.com>
Branch: gc-incminimark-pinning
Changeset: r72906:20eefbef7004
Date: 2014-08-19 15:13 +0200
http://bitbucket.org/pypy/pypy/changeset/20eefbef7004/

Log:	failing test: malloc object of type A, pin it, do GC collect and try
	to malloc object of type B.

diff --git a/rpython/memory/gc/test/test_object_pinning.py b/rpython/memory/gc/test/test_object_pinning.py
--- a/rpython/memory/gc/test/test_object_pinning.py
+++ b/rpython/memory/gc/test/test_object_pinning.py
@@ -4,11 +4,15 @@
 from test_direct import BaseDirectGCTest
 
 S = lltype.GcForwardReference()
-S.become(lltype.GcStruct('pinning_test_struct',
+S.become(lltype.GcStruct('pinning_test_struct1',
                          ('someInt', lltype.Signed),
                          ('next', lltype.Ptr(S)),
                          ('data', lltype.Ptr(S))))
 
+T = lltype.GcForwardReference()
+T.become(lltype.GcStruct('pinning_test_struct2',
+                         ('someInt', lltype.Signed)))
+
 class PinningGCTest(BaseDirectGCTest):
 
     def test_pin_can_move(self):
@@ -545,6 +549,21 @@
         self.pin_shadow_1(self.gc.collect)
 
 
+    def test_malloc_different_types(self):
+        # scenario: malloc two objects of different type and pin them. Do a
+        # minor and major collection in between. This test showed a bug that was
+        # present in a previous implementation of pinning.
+        obj1 = self.malloc(S)
+        self.stackroots.append(obj1)
+        assert self.gc.pin(llmemory.cast_ptr_to_adr(obj1))
+        #
+        self.gc.collect()
+        #
+        obj2 = self.malloc(T)
+        self.stackroots.append(obj2)
+        assert self.gc.pin(llmemory.cast_ptr_to_adr(obj2))
+
+
     def pin_shadow_2(self, collect_func):
         ptr = self.malloc(S)
         adr = llmemory.cast_ptr_to_adr(ptr)


More information about the pypy-commit mailing list