Repository navigation
xmem: mapping or unmapping no pages changes nothing instead of aborting - #167
Merged
Merged
Conversation
XMemMapPhysicalPages with a count of 0, and the GPU's page-mapping copy of a zero-length range, went into unmap with an empty range. Its search for views starting inside asked the view map for a range that runs backwards, which BTreeMap panics on once any view exists; in an extern "system" function that aborts the process. Without that panic the view holding the address would have been unmapped and mapped again as two. unmap now returns at once for a length of 0. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
|
Tested
No game data used. |
edsuuu
referenced
this pull request
in edsuuu/VI-BR-PORT
Nov 24, 2026
…stead of aborting Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Closed
suirentakamura
referenced
this pull request
in suirentakamura/victory-suiren
Nov 24, 2026
xmem: mapping or unmapping no pages changes nothing instead of aborting
itsonlysimbo
pushed a commit
to itsonlysimbo/VIctory
that referenced
this pull request
Nov 24, 2026
xmem: mapping or unmapping no pages changes nothing instead of aborting
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
XMemMapPhysicalPages(address, 0, pages)(with or withoutpages) and the GPU's page-mapping copy of a zero-length range (map_alias(to, from, 0), reached fromCopyPageMappingsBatchX) abort the process once any physical-page view exists.Both call
unmap(physical, base, 0). Thereend == base, so the search for views starting inside the range isviews.range(base + 1..base): a range that runs backwards, whichBTreeMap::rangepanics on ("range start is greater than range end in BTreeMap") whenever the map is not empty. The panic is inside anextern "system"function, so it cannot unwind and the process ends (0xc0000409). Even without the panic the result would be wrong: the view holdingbasepasses theat + size > basetest, so it would be unmapped and mapped again as two views split atbase.unmapnow returns at once for a length of 0: no bytes, no view to give back. Nothing else changes; a count of 1 and up takes the same path as before.I have not seen a title make this call (I have no game files); this is from reading the code. It is a legal argument for both entry points and the cost of the wrong answer is the whole process.
Tested
Windows 11 Pro 10.0.26200, rustc 1.98.1 (
x86_64-pc-windows-msvc), no game data, no GPU involved.New unit test
mapping_no_pages_changes_nothing: maps two pages as one view, then callsXMemMapPhysicalPages(with pages and with null) andmap_alias(with a source and with 0) with a length of 0 at the start of the view, inside it and just past it; checks the view is still one view of two pages, still committed, with its contents. Control: a count of 1 afterwards still unmaps exactly that page and leaves its neighbour mapped.main(9aef3d9) + the test only:cargo test -p victory-hle --lib mapping_no_pagesaborts:panicked at ...\btree\search.rs:121:21: range start is greater than range end in BTreeMap, thenthread caused non-unwinding panic. aborting., exit code0xc0000409.cargo test -p victory-hle --lib xmem: 10 passed, 0 failed (the 9 existing xmem tests and the new one).rustfmt --checkonxmem.rs: clean.cargo clippy -p victory-hle --tests: nothing new (one existingfield_reassign_with_defaultwarning incommit).cargo xtask policy --staged: ok.Not tested: a title run.
Touches only
unmap; #76 rewritesmapand does not overlap.AI-assisted (Claude Code); I ran the tests above myself on the machine described.
🤖 Generated with Claude Code