Repository navigation
fix(libc): skip holes inside an allocation when unmapping a range - #3440
Merged
adriadam10 merged 2 commits intoOct 11, 2026
Merged
adriadam10 merged 2 commits into
adriadam10 merged 2 commits into
Conversation
GuestAllocationsUnmap took the piece containing the cursor from the allocation's original extent. After part of an allocation was unmapped, a later unmap or fixed map starting in that hole still matched the allocation, and replaceRange threw on the hole. Match against the registered range itself and end each piece at its end. RIDE 4 (PPSA01599) maps fixed over a partly unmapped direct memory range. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
One 4-page direct mapping loses its second page to munmap, then pages 1-2 are mapped fixed. The range starts in the hole; before the fix the unmap of the overlap threw "guest protection or unmap range has a hole". The pages around it keep their data. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
9 tasks done
Collaborator
|
Checked build and ctest on the PR merged onto main: |
This was referenced Oct 11, 2026
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.
What
A fixed direct mapping whose range starts in a hole inside an earlier allocation aborts with:
The call path is
sceKernelBatchMap2→DoMapDirect→ReplaceFixedOverlap→UnmapRegistered→GuestAllocationsUnmap→replaceRange.Title: RIDE 4 (PPSA01599, Unreal Engine 4) on main 8ec0e13, a few seconds in, before any window. Under gdb (
ReplaceFixedOverlapbreakpoint plusAPS5_TRACE_MEMORY=1):0x2008e40000+0x2000000, which is part of a larger direct mapping.0x10) at0x2009d20000+0x1790000. That range starts inside the unmapped part and ends in the still-mapped rest.On FreeBSD both the munmap and the fixed map over a partly unmapped range are legal.
Cause:
GuestAllocationsUnmapdecides which range contains the cursor from the allocation's original extent (allocationAddress + allocationBytes), and runs each piece to that extent's end.replaceRangethen meets the hole and throws.Holes between allocations were already skipped (962fc34); holes inside one were not.
Fix
Two lines: test containment against the registered range itself (
address + bytes), and end each piece at that range's end. A cursor in a hole then moves on to the next registered range, exactly as between allocations.lastis still computed from what remains of the allocation, so the Windowsmunmap_releaseof the whole allocation happens on the same final piece as before.Tested
Linux (Arch), GCC, Release, on main 99c1c26.
guest_memorycaseCheckFixedMappingOverHoleInsideAllocation:sceKernelMunmap;ctest: 825/825 (4 video-out flip tests skipped as usual).tools/check_conventions.pypasses.Note: TibixDev's stacked series (#1324 and the PRs built on it) edits the
lastcheck a few lines below. It doesn't touch these lines, but it may need a trivial rebase.Checklist
main; no other open PR implements the same functionsNotImplemented_nid_no_patch); silent stubs are listed in TechnicalDebt.mdfiles or images added to the repository (attach them to this PR)🤖 Generated with Claude Code