Author: Stefan Beyer <[email protected]>
Branch: cpyext-gc-cycle
Changeset: r97319:d326d15810a4
Date: 2019-08-28 13:54 +0200
http://bitbucket.org/pypy/pypy/changeset/d326d15810a4/
Log: Fixed bug when traversing rrc lists in gc
diff --git a/pypy/module/cpyext/state.py b/pypy/module/cpyext/state.py
--- a/pypy/module/cpyext/state.py
+++ b/pypy/module/cpyext/state.py
@@ -192,7 +192,7 @@
# special traverse for list
if self.C._PyList_CheckExact(pyobj) != 0:
- if pyobj.c_ob_pypy_link != 0:
+ if pyobj.c_ob_pypy_link != 0: # actually a refcount now
w_obj = from_ref(space, pyobj)
if w_obj:
debug_print('rrc list traverse ', pyobj)
diff --git a/rpython/memory/gc/rrc/mark.py b/rpython/memory/gc/rrc/mark.py
--- a/rpython/memory/gc/rrc/mark.py
+++ b/rpython/memory/gc/rrc/mark.py
@@ -17,7 +17,7 @@
# Only trace and mark rawrefcounted object if we are not doing
# something special, like building gc.garbage.
- if (self.state == self.STATE_MARKING and self.cycle_enabled):
+ if self.state == self.STATE_MARKING and self.cycle_enabled:
merged_old_list = False
# check objects with finalizers from last collection cycle
if not self._gc_list_is_empty(self.pyobj_old_list):
@@ -58,10 +58,19 @@
self.refcnt_dict.foreach(self._fix_refcnt_back, None)
self.refcnt_dict.delete()
self.refcnt_dict = self.gc.AddressDict()
+ self.use_refcntdict = False
self.state = self.STATE_DEFAULT
return True
+ def to_obj(self, pyobject):
+ if self.use_refcntdict:
+ obj = self.refcnt_dict.get(pyobject)
+ else:
+ obj = llmemory.cast_int_to_adr(
+ self._pyobj(pyobject).c_ob_pypy_link)
+ return llmemory.cast_adr_to_ptr(obj, llmemory.GCREF)
+
def _collect_roots(self, pygclist):
# Initialize the cyclic refcount with the real refcount.
self._collect_roots_init_list(pygclist)
@@ -69,6 +78,7 @@
# Save the real refcount of objects at border
self.p_list_old.foreach(self._obj_save_refcnt, None)
self.o_list_old.foreach(self._obj_save_refcnt, None)
+ self.use_refcntdict = True
# Subtract all internal refcounts from the cyclic refcount
# of rawrefcounted objects
_______________________________________________
pypy-commit mailing list
[email protected]
https://mail.python.org/mailman/listinfo/pypy-commit