xmem: coalesce low-4 GiB guards on retry when no single guard fits #3133
No reviewers
Labels
No labels
accessibility
area: build
area: formats
area: gpu
area: loader
area: runtime
area: shader
bug
documentation
duplicate
enhancement
good first issue
gpu: amd
gpu: intel
gpu: nvidia
help wanted
host: wine
invalid
out of scope
question
request
run report
triage: confirmed
triage: has patch
triage: merge candidate
triage: needs info
triage: needs rebase
triage: needs work
triage: proposed close
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/Marvisak--VIctory!3133
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-3133"
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?
@fuzeofficlal on GitHub · 2026-11-26 09:33 UTC · original
fuzeofficlal:fix/xmem-low-guards-coalesce→main· +429 −5 · 1 files · 1 commits · openProblem
low_guards::retryincrates/victory-hle/src/modules/xmem.rsreleases one guard at a time, invokesallocate(), and immediately re-guards that range on failure before trying the next guard.When a 32-bit
XMemVirtualAllocrequest needs a contiguous span that crosses two or more guards, every single-guard attempt fails and returnsERROR_NOT_ENOUGH_MEMORYeven though the combined address range is unused:MEM_FREE, yet neither guard alone exposes the combined contiguous span.PAGES_2M) straddling a guard boundary: a 2 MiB-alignedVirtualAlloc2window whose start falls in one guard and whose end falls in the next cannot succeed while either guard stays reserved.Fix
MEM_FREEspace (VirtualQueryacross each gap). Single-guard clusters (and guards separated by an active host/title allocation) are skipped.allocate().MEM_FREEportions inside our released guard intervals, merging strictly adjacent released intervals without claiming unguarded free gaps between non-adjacent guards, and preserveGetLastErroracross queries and re-guarding.Verification
Added four targeted regression tests in
modules::xmem::low_guards::tests(confirmed failing onmain63bcca43before the fix and passing after):retry_coalesces_guards_separated_by_a_free_gap(also verifies a refused retry leaves the unguardedMEM_FREEgap free and both guards restored)retry_coalesces_adjacent_guards_and_restores_on_refusal(also verifiesGetLastErrorpreservation)retry_coalesces_guards_straddling_two_mib_alignment(usingVirtualAlloc2withAlignment = 2 * MIB)retry_does_not_coalesce_guards_separated_by_an_allocationFull validation passed:
cargo test -p victory-hle --lockedandVICTORY_D3D12_WARP=1 cargo test -p victory-hle --locked --features diagnostics(156 unit + 2 integration tests passed)cargo clippy --workspace --all-targets --locked -- -D warningsand--all-features(0 warnings)rustfmt --edition 2024 --check(0 diffs on all modified/added lines)cargo test -p xtask --locked policy::tests::repository_passes_policy(asset policy: 191 files ok)@cloph-dsp on GitHub · 2026-11-26 10:23 UTC · original
Independent local verification of head
c283299on Windows 11, Rust 1.100.0/MSVC:cargo test --locked -p victory-hle --lib modules::xmem::low_guards::tests— 6 passed, 0 failed (including all four newretry_coalesces_*tests).git diff --check origin/main HEAD— clean.One deprecation warning appears during compilation, but it is pre-existing in
victory-gpu/src/object.rs(Atomic::fetch_update), unrelated to this diff. SyntheticVirtualAlloc2/VirtualQueryfixtures only; no game assets or DRM material used. AI-assisted (Hy4 flash).@Dukestar69 on GitHub · 2026-11-26 13:30 UTC · original · approved these changes
Verified against
origin/main(63bcca4):cargo test -p victory-hle --lib modules::xmem:: -- --test-threads=1: 18/18 passed (includingretry_coalesces_adjacent_guards_and_restores_on_refusal,retry_coalesces_guards_separated_by_a_free_gap,retry_coalesces_guards_straddling_two_mib_alignment, andretry_does_not_coalesce_guards_separated_by_an_allocation).cargo clippy -p victory-hle --all-targets -- -D warnings: clean.cargo xtask policy: 191 files ok.Cleanly coalesces low-4 GiB guards on retry when no single guard fits while preserving intervening allocations.
Synthetic tests only (no game files used). AI-assisted (Gemini 4 Neon).
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.