summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBen Gamari <ben@smart-cactus.org>2020-04-29 23:20:11 -0400
committerBen Gamari <ben@smart-cactus.org>2020-04-30 12:05:47 -0400
commit0aceee9089eb9d58e481661bfa59b246ccb2c110 (patch)
tree7835cf2a8e0309df7f0fa8f25e7b18b88328175e
parent014ef4a3d9ee30b8add9118950f1f5007143bd1c (diff)
downloadhaskell-0aceee9089eb9d58e481661bfa59b246ccb2c110.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 */