From 84357d1143fe4f9076253160f78fac6c2acc8e5b Mon Sep 17 00:00:00 2001
From: Teo Camarasu <teo.camarasu@tracsis.com>
Date: Thu, 8 Feb 2024 12:10:52 +0000
Subject: [PATCH] rts: only collect live words in nonmoving census when
 non-concurrent

This avoids segfaults when the mutator modifies closures as we examine
them.

Resolves #24393
---
 rts/sm/NonMoving.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/rts/sm/NonMoving.c b/rts/sm/NonMoving.c
index 7a5ce5562727..abe7ebe9703b 100644
--- a/rts/sm/NonMoving.c
+++ b/rts/sm/NonMoving.c
@@ -1221,7 +1221,8 @@ concurrent_marking:
     traceConcSweepEnd();
 #if defined(DEBUG)
     if (RtsFlags.DebugFlags.nonmoving_gc)
-        nonmovingPrintAllocatorCensus(true);
+        // only collect live words if the mutator isn't running.
+        nonmovingPrintAllocatorCensus(!concurrent);
 #endif
 #if defined(TRACING)
     if (RtsFlags.TraceFlags.nonmoving_gc)
-- 
GitLab