diff options
| author | Ben Gamari <ben@smart-cactus.org> | 2023-01-19 13:52:47 -0500 |
|---|---|---|
| committer | Ben Gamari <ben@smart-cactus.org> | 2023-04-12 07:56:29 -0400 |
| commit | 85a9026cd1f80ae1b3658256ecad56f808b25a7d (patch) | |
| tree | d34ef81428faf42642126d04377e9da5ec5191ae | |
| parent | 9424f0cd96dcf80fd2a7fb62899219f9abbc7044 (diff) | |
| download | haskell-85a9026cd1f80ae1b3658256ecad56f808b25a7d.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.
(cherry picked from commit a9062eaa577b3f1edf07908e57832524b5525d7d)
| -rw-r--r-- | rts/sm/Sanity.c | 16 |
1 files changed, 13 insertions, 3 deletions
diff --git a/rts/sm/Sanity.c b/rts/sm/Sanity.c index 906f91d53c..2243424fcd 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 -------------------------------------------------------------------------- */ @@ -910,7 +915,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) @@ -927,7 +937,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); @@ -1128,7 +1138,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); |
