Author: Armin Rigo <ar...@tunes.org> Branch: Changeset: r94331:f154dd05a3a5 Date: 2018-04-14 23:13 +0200 http://bitbucket.org/pypy/pypy/changeset/f154dd05a3a5/
Log: Small tweaks and documentation for issue2752 diff --git a/pypy/doc/whatsnew-head.rst b/pypy/doc/whatsnew-head.rst --- a/pypy/doc/whatsnew-head.rst +++ b/pypy/doc/whatsnew-head.rst @@ -6,3 +6,7 @@ .. startrev: f22145c34985 +.. branch: issue2752 + +Fix a rare GC bug that was introduced more than one year ago, but was +not diagnosed before issue #2752. diff --git a/rpython/memory/gc/incminimark.py b/rpython/memory/gc/incminimark.py --- a/rpython/memory/gc/incminimark.py +++ b/rpython/memory/gc/incminimark.py @@ -731,14 +731,11 @@ def move_out_of_nursery(self, obj): # called twice, it should return the same shadow object, - # and not creating another shadow object - if self.header(obj).tid & GCFLAG_HAS_SHADOW: - shadow = self.nursery_objects_shadows.get(obj) - ll_assert(shadow != llmemory.NULL, - "GCFLAG_HAS_SHADOW but no shadow found") - else: - shadow = self._allocate_shadow(obj) - + # and not creating another shadow object. As a safety feature, + # when called on a non-nursery object, do nothing. + if not self.is_in_nursery(obj): + return obj + shadow = self._find_shadow(obj) if (self.header(obj).tid & GCFLAG_SHADOW_INITIALIZED) == 0: self.header(obj).tid |= GCFLAG_SHADOW_INITIALIZED totalsize = self.get_size(obj) @@ -2079,13 +2076,12 @@ ll_assert(newobj != llmemory.NULL, "GCFLAG_HAS_SHADOW but no shadow found") newhdr = newobj - size_gc_header # - # Remove the flag GCFLAG_HAS_SHADOW, so that it doesn't get - # copied to the shadow itself. - self.header(obj).tid &= ~GCFLAG_HAS_SHADOW + # The flags GCFLAG_HAS_SHADOW and GCFLAG_SHADOW_INITIALIZED + # have no meaning in non-nursery objects. We don't need to + # remove them explicitly here before doing the copy. tid = self.header(obj).tid if (tid & GCFLAG_SHADOW_INITIALIZED) != 0: copy = False - self.header(obj).tid &= ~GCFLAG_SHADOW_INITIALIZED # totalsize = size_gc_header + self.get_size(obj) self.nursery_surviving_size += raw_malloc_usage(totalsize) _______________________________________________ pypy-commit mailing list pypy-commit@python.org https://mail.python.org/mailman/listinfo/pypy-commit