summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBen Gamari <ben@smart-cactus.org>2020-04-29 23:20:11 -0400
committerMarge Bot <ben+marge-bot@smart-cactus.org>2020-05-06 04:40:08 -0400
commit420b957df9d831632a3edab682778b11734255f1 (patch)
treec7284c14319c2a140bbb302cf23fb68515d6636a
parent7ab6ab093c86227b6d33a5185ebbd11928ac9754 (diff)
downloadhaskell-420b957df9d831632a3edab682778b11734255f1.tar.gz
rts: Zero block flags with -DZ
Block flags are very useful for determining the state of a block. However, some block allocator users don't touch them, leading to misleading values. Ensure that we zero then when zero-on-gc is set. This is safe and makes the flags more useful during debugging.
-rw-r--r--rts/sm/BlockAlloc.c12
1 files changed, 12 insertions, 0 deletions
diff --git a/rts/sm/BlockAlloc.c b/rts/sm/BlockAlloc.c
index b3e1e2ce75..2bf497197e 100644
--- a/rts/sm/BlockAlloc.c
+++ b/rts/sm/BlockAlloc.c
@@ -233,6 +233,12 @@ initGroup(bdescr *head)
last->blocks = 0;
last->link = head;
}
+
+#if defined(DEBUG)
+ for (uint32_t i=0; i < head->blocks; i++) {
+ head[i].flags = 0;
+ }
+#endif
}
#if SIZEOF_VOID_P == SIZEOF_LONG
@@ -792,6 +798,12 @@ freeGroup(bdescr *p)
ASSERT(p->free != (P_)-1);
+#if defined(DEBUG)
+ for (uint32_t i=0; i < p->blocks; i++) {
+ p[i].flags = 0;
+ }
+#endif
+
node = p->node;
p->free = (void *)-1; /* indicates that this block is free */