Author: Gregor Wegberg <[email protected]>
Branch: gc-incminimark-pinning
Changeset: r72531:1f3c0f2801cb
Date: 2014-07-26 15:48 +0200
http://bitbucket.org/pypy/pypy/changeset/1f3c0f2801cb/
Log: add test to make sure not referenced pinned objects are collected
Basically we have an old object pointing to a young pinned one. The
moment the old object is not used anymore (not referenced from
stack) the GC should not only collect the old object but also the
still pinned one.
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
@@ -96,6 +96,29 @@
def test_simple_pin_unpin_stack_minor_collect(self):
self.simple_pin_unpin_stack(self.gc.minor_collection)
+ def test_pinned_obj_collected_after_old_object_collected(self):
+ root_ptr = self.malloc(S)
+ root_ptr.someInt = 999
+ self.stackroots.append(root_ptr)
+ self.gc.collect()
+
+ root_ptr = self.stackroots[0]
+ next_ptr = self.malloc(S)
+ next_ptr.someInt = 111
+ assert self.gc.pin(llmemory.cast_ptr_to_adr(next_ptr))
+ self.write(root_ptr, 'next', next_ptr)
+ self.gc.collect()
+ # check still alive
+ assert self.gc.is_in_nursery(llmemory.cast_ptr_to_adr(root_ptr.next))
+ self.stackroots.remove(root_ptr)
+ self.gc.collect()
+ # root_ptr was collected and therefore also the pinned object should
+ # be gone
+ try:
+ next_ptr.someInt = 101
+ except RuntimeError as ex:
+ assert "freed" in str(ex)
+
def test_pin_referenced_from_stackroot_young(self):
#
# create two objects and reference the pinned one
_______________________________________________
pypy-commit mailing list
[email protected]
https://mail.python.org/mailman/listinfo/pypy-commit