Repository navigation
Account for committed memory when VMChunkCreate fails after ChunkInit starts - #320
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
… starts. VMChunkCreate maps the chunk structure's grain with vmArenaMap, which adds it to arena->committed, but its failChunkInit path unmapped it with the raw VMUnmap, which does not subtract it. A grow refused at the commit limit therefore left the arena over-counting committed memory, and mps_arena_destroy failed the check at arenavm.c:799. It now calls VMChunkFinish, which unmaps the chunk's overhead through vmArenaUnmap and finishes the VM. ChunkInit no longer calls the arena class's chunkFinish when ArenaFreeLandInsert fails. Its caller undoes the class's chunkInit, as it must for every other failure; calling it in both places made the VM arena unmap and finish the chunk's VM twice. Fixes GitHub issue Ravenbrook#319 <Ravenbrook#319>.
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 #319.
VMChunkCreate(code/arenavm.c) maps the chunk structure's grain withvmArenaMap, which adds it toarena->committed. WhenChunkInitthen failed,failChunkInitunmapped the grain with the rawVMUnmap, which does not subtract it. Each grow refused at the commit limit therefore left the arena over-counting committed memory, andmps_arena_destroylater failedAVER(arena->committed == VMMapped(VMArenaVM(vmArena)))at arenavm.c:799.failChunkInitnow callsVMChunkFinish. That function unmaps the chunk's overhead throughvmArenaUnmap, covering the chunk structure and any bit tablesVMChunkInitmapped, and then finishes the VM.That change also needs
ChunkInit(code/tract.c) to stop calling the class'schunkFinishwhenArenaFreeLandInsertfails. Otherwise that failure finishes the chunk twice. The old code already did that, so this fixes a second problem:VMChunkFinishreleased the VM.failChunkInitcalledVMUnmapandVMFinishon the stack copy of the same VM.VirtualFree(MEM_DECOMMIT)on released address space, which I read as failingAVER(b != 0)at vmw3.c:225.MAP_FIXEDmapping and a secondmunmapover a range another thread may since have been given.The client arena's
chunkFinishdoes nothing and itsclientChunkCreatehas nothing to undo, so moving the responsibility to the caller changes nothing there.Tested on macOS arm64 (16 KiB pages) with clang:
mps_arena_destroycompletes without the assertion, where unchanged master fails it.arenacv,fotest,apss,locusss,mpmssandamcsspass in the cool variety.The
ArenaFreeLandInsertfailure path and Windows have not been run.