Author: Armin Rigo <ar...@tunes.org> Branch: cpyext-gc-support Changeset: r80292:c82b950212fd Date: 2015-10-16 20:17 +0200 http://bitbucket.org/pypy/pypy/changeset/c82b950212fd/
Log: Extra tests for the cases where the object pair dies before the first minor collection. The rules are that create_link_pypy() always frees the PyPy object in this case; if tp_dealloc is called later, it will be on a detached PyObject. diff --git a/rpython/memory/gc/test/test_rawrefcount.py b/rpython/memory/gc/test/test_rawrefcount.py --- a/rpython/memory/gc/test/test_rawrefcount.py +++ b/rpython/memory/gc/test/test_rawrefcount.py @@ -90,6 +90,16 @@ self.gc.check_no_more_rawrefcount_state() assert self.dealloc == [] + def test_rawrefcount_dies_quickly(self): + p1, p1ref, r1, r1addr, check_alive = ( + self._rawrefcount_pair(42, is_direct=True)) + check_alive(0) + self.gc.minor_collection() + py.test.raises(RuntimeError, "r1.ob_refcnt") # dead + py.test.raises(RuntimeError, "p1.x") # dead + self.gc.check_no_more_rawrefcount_state() + assert self.dealloc == [] + def test_rawrefcount_objects_collection_survives_from_obj(self): p1, p1ref, r1, r1addr, check_alive = ( self._rawrefcount_pair(42, is_direct=True)) @@ -151,3 +161,15 @@ assert self.dealloc == [r1addr] self.gc.check_no_more_rawrefcount_state() lltype.free(r1, flavor='raw') + + def test_pypy_nondirect_dies_quickly(self): + p1, p1ref, r1, r1addr, check_alive = ( + self._rawrefcount_pair(42, is_direct=False)) + check_alive(0) + self.gc.minor_collection() + py.test.raises(RuntimeError, "p1.x") # dead + assert r1.ob_refcnt == 0 + assert r1.ob_pypy_link == 0 + assert self.dealloc == [r1addr] + self.gc.check_no_more_rawrefcount_state() + lltype.free(r1, flavor='raw') _______________________________________________ pypy-commit mailing list pypy-commit@python.org https://mail.python.org/mailman/listinfo/pypy-commit