summaryrefslogtreecommitdiff
path: root/rts
diff options
context:
space:
mode:
authorBen Gamari <ben@smart-cactus.org>2023-01-19 13:52:47 -0500
committerMarge Bot <ben+marge-bot@smart-cactus.org>2023-03-08 15:02:31 -0500
commit4a7650d75752fcde2fc5bc23913e4116ae2ec582 (patch)
treeaa9977f4ba98c4cf13b0e03e8c59d4119a4cae3d /rts
parent56e669c11208bba136c44ee7154b59e0d4d39c87 (diff)
downloadhaskell-4a7650d75752fcde2fc5bc23913e4116ae2ec582.tar.gz
rts/Sanity: Fix block count assertion with non-moving collector
The nonmoving collector does not use `oldest_gen->blocks` to track its block list. However, it nevertheless updates `oldest_gen->n_blocks` to ensure that its size is accounted for by the storage manager. Consequently, we must not attempt to assert consistency between the two.
Diffstat (limited to 'rts')
-rw-r--r--rts/sm/Sanity.c16
1 files changed, 13 insertions, 3 deletions
diff --git a/rts/sm/Sanity.c b/rts/sm/Sanity.c
index 74260955bc..a8cf074989 100644
--- a/rts/sm/Sanity.c
+++ b/rts/sm/Sanity.c
@@ -56,6 +56,11 @@ static W_ countNonMovingHeap ( struct NonmovingHeap *heap );
// the HEAP_ALLOCED macro in function form. Useful for use in GDB or similar.
int isHeapAlloced ( StgPtr p) { return HEAP_ALLOCED(p); }
+static bool isNonmovingGen(generation *gen)
+{
+ return RtsFlags.GcFlags.useNonmoving && gen == oldest_gen;
+}
+
/* -----------------------------------------------------------------------------
Check stack sanity
-------------------------------------------------------------------------- */
@@ -927,7 +932,12 @@ static void checkGeneration (generation *gen,
uint32_t n;
gen_workspace *ws;
- ASSERT(countBlocks(gen->blocks) == gen->n_blocks);
+ // N.B. the nonmoving collector's block list does not live on
+ // oldest_gen->blocks. See Note [Live data accounting in nonmoving
+ // collector]..
+ if (!isNonmovingGen(gen)) {
+ ASSERT(countBlocks(gen->blocks) == gen->n_blocks);
+ }
ASSERT(countBlocks(gen->large_objects) == gen->n_large_blocks);
#if defined(THREADED_RTS)
@@ -944,7 +954,7 @@ static void checkGeneration (generation *gen,
if (!after_major_gc) return;
#endif
- if (RtsFlags.GcFlags.useNonmoving && gen == oldest_gen) {
+ if (isNonmovingGen(gen)) {
ASSERT(countNonMovingSegments(nonmovingHeap.free) == (W_) nonmovingHeap.n_free * NONMOVING_SEGMENT_BLOCKS);
ASSERT(countBlocks(nonmoving_large_objects) == n_nonmoving_large_blocks);
ASSERT(countBlocks(nonmoving_marked_large_objects) == n_nonmoving_marked_large_blocks);
@@ -1145,7 +1155,7 @@ static W_
genBlocks (generation *gen)
{
W_ ret = 0;
- if (RtsFlags.GcFlags.useNonmoving && gen == oldest_gen) {
+ if (isNonmovingGen(gen)) {
// See Note [Live data accounting in nonmoving collector].
ASSERT(countNonMovingHeap(&nonmovingHeap) == gen->n_blocks);
ret += countAllocdBlocks(nonmoving_large_objects);