xmem: enforce 16 MiB minimum and pre-validate pages in map_whole #14
No reviewers
Labels
No labels
accessibility
bug
documentation
duplicate
enhancement
good first issue
help wanted
invalid
question
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/Belobug--VIctory-Belobug-AMD!14
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-14"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
@adritoyalser on GitHub · 2026-11-25 11:52 UTC · original
adritoyalser:fix/xmem-whole-min-size→main· +47 −2 · 1 files · 1 commits · openSummary
Fixes #8 (Refs #2).
Commit
41b9207fintroducedmap_wholeincrates/victory-hle/src/modules/xmem.rsto show large same-sized physical reservations (like GTA VI's 185 MiB GPU heap) in one contiguous view, paired withvictory-gpu/src/shadow.rs:1086(and:2256on71652a2, originally:645in41b9207f) refusing in-place GPU use for anyMEM_MAPPEDview smaller than 16 MiB (16 << 20).Because
map_wholeonly checked the upper bound (WHOLE = 1 GiB) and had no matching lower bound, small reservations (e.g., 2–4 pages) were promoted tophysical.whole, which coalesced caller-split placeholders, committed unrequested pages, made partialunmapcalls no-ops, and broke all 5xmemtests reported in #8 and #2.Changes
crates/victory-hle/src/modules/xmem.rs:WHOLE_MIN = 16 * MIB(matchingvictory-gpu's 16 MiB in-place view threshold) and gatedmap_wholeon(WHOLE_MIN..=WHOLE).contains(&len).first.sectionbefore callingVirtualFree(..., COALESCE)/map_view, preventing an invalid initial mapping call from leaving a reservation mapped whole.trueearly forlen == 0inmap_aliasbefore checkingin_whole(consistent withunmap).large_reservation_is_shown_wholeandwhole_map_rejects_invalid_page_without_mapping_wholeregression tests.Verification
cargo test -q -p victory-hle --lib --locked xmem -- --test-threads=1— 16 passed, 0 failed (all 5 failing tests from #8 / #2 now pass, plus 2 new tests).cargo clippy -q -p victory-hle --lib --locked --no-deps -- -D warnings— 0 warnings.@Ekabusto on GitHub · 2026-11-25 12:47 UTC · original
Checked locally:
cargo test -p victory-hle --libpasses (104 passed, 1 ignored), with the tests running in parallel (not only--test-threads=1). Clippy reports what it does onmainand nothing new.Overlap: this and #16 (mine) fix the same five
xmemfailures from #2 and #8 in different ways, and they conflict. #16 keepsmap_wholefor any size and changes the tests; this PR limits it to 16 MiB and up and adds page validation. Both include the samelen == 0early return inmap_alias. I think this one is the better fix for the title: a whole view under 16 MiB gains nothing on the GPU side, which uses mapped views in place only from 16 MiB up, and it still commits the whole section. If this is merged, #16 should be closed; its new test maps 3 pages, under this minimum.One small correction to the description: the GPU side's 16 MiB check is at
victory-gpu/src/shadow.rs:1086on71652a2(and:2256), not:645.Reviewed on Windows 11 (build 26300), Rust 1.98.1, each PR in its own worktree; no game data, not run in the game. AI-assisted (Claude Code).
@adritoyalser on GitHub · 2026-11-25 14:11 UTC · original
Thanks for testing this in parallel and catching the line-number drift @Ekabusto! Updated the PR description to point to
victory-gpu/src/shadow.rs:1086(and:2256) on71652a2.@enriquebruno12 on GitHub · 2026-11-25 14:38 UTC · original
Tested this patch on Windows against my local checkout. Before applying it, five xmem tests failed. With the patch, all 16 xmem tests passed both in parallel and with --test-threads=1. The only failure in the full victory-hle library run was only_loopback_is_reachable, which also failed with the original test binary in the same environment.
@Adika713 on GitHub · 2026-11-25 15:20 UTC · original
Verified on the machine from #2/#107: AMD Radeon RX 6950 XT (RDNA2),
Ryzen 5 3600, 32 GB RAM, Windows 11, Rust 1.98.1 / Cargo 1.98.1.
No game data; the title was not run.
I fetched PR head
5dc3396dbd374650de5e621519c0a82154256a20into a detachedworktree and used an isolated
CARGO_TARGET_DIRfor each tree. Reusing onetarget dir across main and a worktree can silently run the main test binary,
so these numbers are from separate target dirs (
_agent_tmp\target-main-verifyand
_agent_tmp\target-pr14-verify, both underF:\VIctory-Belobug-AMD).Before, at
upstream/main01aadd193d57e71fb4d57810eb2fdd1bc95c950b, fromF:\VIctory-Belobug-AMDwithCARGO_TARGET_DIR=F:\VIctory-Belobug-AMD\_agent_tmp\target-main-verify:@Adika713 on GitHub · 2026-11-25 15:23 UTC · original
Verified on the machine from #2/#107: AMD Radeon RX 6950 XT (RDNA2),
Ryzen 5 3600, 32 GB RAM, Windows 11, Rust 1.98.1 / Cargo 1.98.1.
No game data; the title was not run.
I fetched PR head
5dc3396dbd374650de5e621519c0a82154256a20into a detachedworktree and used an isolated
CARGO_TARGET_DIRfor each tree. Reusing onetarget dir across main and a worktree can silently run the main test binary,
so these numbers are from separate target dirs (
_agent_tmp\target-main-verifyand
_agent_tmp\target-pr14-verify, both underF:\VIctory-Belobug-AMD).Before, at
upstream/main01aadd193d57e71fb4d57810eb2fdd1bc95c950b, fromF:\VIctory-Belobug-AMDwithCARGO_TARGET_DIR=F:\VIctory-Belobug-AMD\_agent_tmp\target-main-verify:test result: FAILED. 9 passed; 5 failed; 0 ignored; 0 measured; 89 filtered out.victory-hlelib: exit 101 —test result: FAILED. 97 passed; 5 failed; 1 ignored; 0 measured; 0 filtered out.a_run_keeps_the_placeholders_it_spans,a_run_maps_across_two_placeholders,a_run_maps_again_after_a_partial_unmap,mapping_no_pages_changes_nothing, andphysical_pages_map_alias_and_unmap.After, at PR head
5dc3396dbd374650de5e621519c0a82154256a20, from a detachedworktree at
F:\VIctory-Belobug-AMD\_agent_tmp\pr-14withCARGO_TARGET_DIR=F:\VIctory-Belobug-AMD\_agent_tmp\target-pr14-verify:test result: ok. 16 passed; 0 failed; 0 ignored; 0 measured; 89 filtered out(plus doc-tests:
0 passed; 0 failed; 0 ignored; 0 measured; 1 filtered out).victory-hlelib: exit 0 —test result: ok. 104 passed; 0 failed; 1 ignored; 0 measured; 0 filtered out.Overlap check: I also ran the same five-test command on PR heads #93 (
0cbedb9)and #16 (
83cce99); both pass. #99 (5c0efcc), #39 (73e6eac) and #52 stillfail all five. #89 and #100 do not touch
crates/victory-hle/src/modules/xmem.rs.I did not write a competing fix.
Not tested: the game, because no game files or paths were supplied.
AI-assisted: OpenCode, model Big Pickle. No game data.
View command line instructions
Checkout
From your project repository, check out a new branch and test the changes.Merge
Merge the changes and update on Forgejo.