From d1bb16ed3e18a4f41fcfe31f0bf57dbaf589d6c5 Mon Sep 17 00:00:00 2001 From: Ben Gamari Date: Thu, 23 Mar 2023 22:37:11 -0400 Subject: nonmoving: Disable slop-zeroing As noted in #23170, the nonmoving GC can race with a mutator zeroing the slop of an updated thunk (in much the same way that two mutators would race). Consequently, we must disable slop-zeroing when the nonmoving GC is in use. Closes #23170 --- rts/include/rts/storage/ClosureMacros.h | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) (limited to 'rts') diff --git a/rts/include/rts/storage/ClosureMacros.h b/rts/include/rts/storage/ClosureMacros.h index af4d13a198..57e9be2de8 100644 --- a/rts/include/rts/storage/ClosureMacros.h +++ b/rts/include/rts/storage/ClosureMacros.h @@ -479,11 +479,13 @@ EXTERN_INLINE StgWord8 *mutArrPtrsCard (StgMutArrPtrs *a, W_ n) memory we're about to zero. Thus, with the THREADED RTS and +RTS -N2 or greater we must not zero - immutable closure's slop. + immutable closure's slop. Similarly, the concurrent GC's mark thread + may race when a mutator during slop-zeroing. Consequently, we also disable + zeroing when the non-moving GC is in use. Hence, an immutable closure's slop is zeroed when either: - - PROFILING && era > 0 (LDV is on) or + - PROFILING && era > 0 (LDV is on) && !nonmoving-gc-enabled or - !THREADED && DEBUG Additionally: @@ -535,8 +537,10 @@ zeroSlop (StgClosure *p, #endif ; - // Only if we're running single threaded. - const bool can_zero_immutable_slop = getNumCapabilities() == 1; + const bool can_zero_immutable_slop = + // Only if we're running single threaded. + getNumCapabilities() == 1 + && !RTS_DEREF(RtsFlags).GcFlags.useNonmoving; // see #23170 const bool zero_slop_immutable = want_to_zero_immutable_slop && can_zero_immutable_slop; -- cgit v1.2.1