From fd50ed9eee76273581392ce90acf44b89494025b Mon Sep 17 00:00:00 2001 From: Michael Bentley Date: Sun, 25 Oct 2026 18:09:29 -0400 Subject: [PATCH] Advance the trace once in ArenaStartCollect before releasing the arena. ArenaStartCollect starts the trace with TraceStartCollectAll, which flips it, and then calls ArenaRelease, which advances the trace only if a poll is due. Usually none is, so mps_arena_start_collect returned with a flipped trace whose band was still RankAMBIG, and a read barrier hit before the next poll failed the NOTREACHED in TraceRankForAccess at trace.c:989. ArenaStartCollect now advances the trace once before releasing the arena, as TracePoll and ArenaStep do after starting a trace. That leaves the band at RankEXACT or later, or leaves no segment grey for the trace. Fixes GitHub issue #321 . --- code/traceanc.c | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/code/traceanc.c b/code/traceanc.c index a6f4f3f49c..f1e7d4d010 100644 --- a/code/traceanc.c +++ b/code/traceanc.c @@ -634,6 +634,17 @@ Res ArenaStartCollect(Globals globals, TraceStartWhy why) res = TraceStartCollectAll(&trace, arena, why); if(res != ResOK) goto failStart; + + /* The trace has been flipped, so the mutator may hit the read + * barrier on a grey segment as soon as the arena is released. + * TraceRankForAccess needs the trace to be past its initial band, + * RankAMBIG, but the band only advances in traceFindGrey. + * ArenaRelease advances the trace only if a poll is due, so advance + * it once here, as TracePoll and ArenaStep do after starting a + * trace. Afterwards either the band is past RankAMBIG or no + * segment is grey for the trace. */ + TraceAdvance(trace); + ArenaRelease(globals); return ResOK;