1. Pypy
  2. Untitled project
  3. pypy

Commits

Armin Rigo  committed 375a03b

Add more precise asserts, designed to catch most cases where 'obj' is nonsense (it points inside an object, where there is a pointer).

  • Participants
  • Parent commits c0b31ff
  • Branches default

Comments (0)

Files changed (1)

File pypy/rpython/memory/gc/minimark.py

View file
  • Ignore whitespace
 GCFLAG_HAS_CARDS    = first_gcflag << 5
 GCFLAG_CARDS_SET    = first_gcflag << 6     # <- at least one card bit is set
 
+TID_MASK            = (first_gcflag << 7) - 1
+
 
 FORWARDSTUB = lltype.GcStruct('forwarding_stub',
                               ('forw', llmemory.Address))
         that can never be set on a young object -- except if tid == -42.
         """
         assert self.is_in_nursery(obj)
-        result = (self.header(obj).tid & GCFLAG_FINALIZATION_ORDERING != 0)
+        tid = self.header(obj).tid
+        result = (tid & GCFLAG_FINALIZATION_ORDERING != 0)
         if result:
-            ll_assert(self.header(obj).tid == -42, "bogus header for young obj")
+            ll_assert(tid == -42, "bogus header for young obj")
+        else:
+            ll_assert(tid != 0, "bogus header (1)")
+            ll_assert(tid & ~TID_MASK == 0, "bogus header (2)")
         return result
 
     def get_forwarding_address(self, obj):