[pypy-commit] pypy gc-incminimark-pinning: add failing test revealing a bug where a pointer in 'objects_to_trace' becomes dead

groggi noreply at buildbot.pypy.org
Sat Aug 23 21:42:11 CEST 2014


Author: Gregor Wegberg <code at gregorwegberg.com>
Branch: gc-incminimark-pinning
Changeset: r73014:259c0aa0d1f7
Date: 2014-08-23 21:39 +0200
http://bitbucket.org/pypy/pypy/changeset/259c0aa0d1f7/

Log:	add failing test revealing a bug where a pointer in
	'objects_to_trace' becomes dead

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
@@ -597,6 +597,22 @@
         assert self.gc.pin(llmemory.cast_ptr_to_adr(obj2))
 
 
+    def test_objects_to_trace_bug(self):
+        # scenario: In a previous implementation there was a bug because of a
+        # dead pointer inside 'objects_to_trace'. This was caused by the first
+        # major collection step that added the pointer to the list and right
+        # after the collection step the object is unpinned and freed by the minor
+        # collection, leaving a dead pointer in the list.
+        pinned_ptr = self.malloc(T)
+        pinned_ptr.someInt = 101
+        self.stackroots.append(pinned_ptr)
+        pinned_adr = llmemory.cast_ptr_to_adr(pinned_ptr)
+        assert self.gc.pin(pinned_adr)
+        self.gc.debug_gc_step()
+        self.gc.unpin(pinned_adr)
+        self.gc.debug_gc_step()
+
+
     def pin_shadow_2(self, collect_func):
         ptr = self.malloc(T)
         adr = llmemory.cast_ptr_to_adr(ptr)


More information about the pypy-commit mailing list