Repository navigation
Advance the trace once in ArenaStartCollect before releasing the arena - #322
Open
defmacro-jam wants to merge 1 commit into
Open
defmacro-jam wants to merge 1 commit into
defmacro-jam wants to merge 1 commit into
Conversation
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 Ravenbrook#321 <Ravenbrook#321>.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #321.
ArenaStartCollect(code/traceanc.c) starts the trace withTraceStartCollectAll, which flips it, and then callsArenaRelease, which advances the trace only if a poll is due. Usually none is, somps_arena_start_collectreturned with a flipped trace whose band was stillRankAMBIG. A read barrier hit before the next poll then failed theNOTREACHEDinTraceRankForAccessat trace.c:989.ArenaStartCollectnow callsTraceAdvanceonce beforeArenaRelease, asTracePollandArenaStepdo after starting a trace.Why one advance is enough:
TraceFLIPPEDwhenTraceStartCollectAllsucceeds, soTraceAdvancecallstraceFindGrey.RankAMBIG,traceFindGreysearches nothing and callstraceBandAdvance, which moves the band toRankEXACT.RankEXACTor later, whichTraceAdvancescans without changing the band, or it runs out of bands. In that case no segment is grey for the trace,traceBandAdvanceresets the band toRankMIN, andTraceAdvancemoves the trace toTraceRECLAIM.RankAMBIG, or nothing is grey for the trace and the read barrier cannot be hit.ArenaStepcan already return with a trace in thatTraceRECLAIMstate, so the arena is left in no state it could not reach before.awlSegCanTrySingleAccess(poolawl.c:345) callsTraceRankForAccesson any barrier hit on a weak AWL segment while a trace is flipped, grey or not. After this change it can seeRankAMBIGonly in theTraceRECLAIMstate above. I believe a write hit there would need a reachable object in a condemned weak AWL segment that is not grey, and the flip greys any such segment when it marks the object from a root, but I have not tested that path, and this change does not alter it.A single step from
TraceFLIPPEDcannot finish the trace (TraceAdvancemoves it at most toTraceRECLAIM), so unlikeTracePollthere is no finished trace to destroy.ArenaCollect, the only other caller ofArenaStartCollect, parks the arena straight afterwards, so the extra step makes no difference there.Tested on macOS arm64 (16 KiB pages) with Apple clang:
RankEXACT.zmess(the only test that callsmps_arena_start_collect),amcss,amcsshe,apss,mpmss,arenacv,fotest,locusss,mpsicv,finalcv,walkt0,awlut,amsss,steptest,ztfmandzcollpass in the cool variety.Other platforms, the hot variety of the test suite, and the multi-threaded case we first saw it in have not been run against this change.