xmem: 32-bit XMemAllocDefault blocks get the alignment they ask for #2184
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!2184
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-2184"
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?
@BastienRodz on GitHub · 2026-11-25 07:08 UTC · original
BastienRodz:hle/xmem-32bit-align→main· +56 −6 · 1 files · 1 commits · openWhat's wrong
XMemAllocDefaulthonours the alignment field ofattributes(log2, 5 bits at 24) for host-heap blocks, but itsALLOC_32BITbranch callsXMemVirtualAllocwith no alignment. That path setsMEM_ADDRESS_REQUIREMENTS::Alignmentonly forPAGES_2M, so a 32-bit block asked for at 128 KiB, 256 KiB, 1 MiB or 2 MiB gets the 64 KiB allocation granularity instead. The module header says alignment is one of the address constraints it honours.What the fix does
XMemVirtualAllocinto a privatevirtual_allocthat takes theAlignmentto request.XMemVirtualAllockeeps its behaviour (2 MiB forPAGES_2M, else 0).XMemAllocDefaultpasses the asked alignment when it is above 64 KiB, and 0 otherwise:MEM_ADDRESS_REQUIREMENTSrequires a nonzero alignment to be at least the allocation granularity, and 0 already gives 64 KiB.Tests
New
modules::xmem::tests::alloc_32bit_honours_alignments_above_64k: four live 32-bit blocks per alignment (16 B, 64 KiB, 128 KiB, 256 KiB, 2 MiB), each checked below 4 GiB, aligned, and writable.main(940d32f) it fails:field 0x11: 0x10000 is not 131072-byte aligned.modules::xmem::tests pass (11 of 11, Wine 10, x86_64-pc-windows-msvc).Not tested
No title run. The title imports
xmem.dll!XMemAlloc, but whether it asks for 32-bit blocks aligned above 64 KiB is not measured. #2022 changes the host-heap branch of the same function; the two don't overlap.Fixes #2183
AI-assisted (Gemini 4 Neon found and wrote it, Claude Code reviewed and verified it). No game data used.
🤖 Generated with Claude Code
@kotekompotek on GitHub · 2026-11-25 09:18 UTC · original
Verified on Windows 10 / GTX 1050,
cargo test -p victory-hle --locked xmem: 11/11 pass, including the newalloc_32bit_honours_alignments_above_64k.Mechanics check out:
PAGEis 64 KiB, soalign > PAGEcorrectly maps "at or below the allocation granularity" toAlignment = 0, whichMEM_ADDRESS_REQUIREMENTSrequires (nonzero must be ≥64 KiB).XMemVirtualAllockeeps its old contract (2 MiB only forPAGES_2M), and the four-live-blocks-per-alignment test design guards against 64 KiB slots landing on coarse boundaries by chance — it does fail on940d32fas reported.@Marvisak on GitHub · 2026-11-25 12:38 UTC · original
Automated triage for the maintainers.
Merge candidate.
XMemAllocDefaultwithALLOC_32BIT(crates/victory-hle/src/modules/xmem.rs) now honours the attributes' alignment field. It reads the same field aslayout(attributes >> ALIGNMENT_SHIFT & 0x1f). Alignments above the 64 KiB granularity are passed asMEM_ADDRESS_REQUIREMENTS::Alignment, and anything at or below it uses 0. That is right, becauseVirtualAlloc2only accepts 0 or at least the allocation granularity, and 0 already gives 64 KiB.XMemVirtualAllockeeps its old behaviour (2 MiB only forPAGES_2M) through the newvirtual_allochelper.alloc_32bit_honours_alignments_above_64kholds four live blocks per alignment, so a block can't pass by landing on a coarse boundary by chance. A reviewer in the thread reports that it fails onmain. CIcheckpasses, and the branch merges cleanly.Generated by Claude Code
@catminou4 on GitHub · 2026-11-25 07:17 UTC · original · reviewed
Static review only: victory-hle is Windows-only — nothing compiles or runs on macOS; source review of the diff.
xmem: 32-bit XMemAllocDefault blocks get their alignment — allocator alignment fix for 32-bit title heaps.
@jaschinski97-ops on GitHub · 2026-11-25 16:18 UTC · original · reviewed
Native Windows 11 verification of unchanged head
8954790, including integration with #2022 and current main67e8ae1.940d32fand current main67e8ae1reproduces the failure: field0x11can return an address with remainder 65,536 modulo 131,072. This is a real before/after check on native Windows.Reproducible evidence branch, exact heads, commands and results. Original commits and authors are preserved; no implementation edits or competing PR.
Windows 11 Pro build 26300, Rust 1.98.1
x86_64-pc-windows-gnu, LLVM-MinGW. This native GNU run complements the existing MSVC CI. Synthetic fixtures only, no title data or gameplay claim. AI-assisted verification with Codex. Claim: #1633.@fuzeofficlal on GitHub · 2026-11-26 19:00 UTC · original · approved these changes
Reviewed
8954790b4fefmerged cleanly onto63bcca43.The change in
crates/victory-hle/src/modules/xmem.rs:87-115and305-319is minimal and exact:virtual_alloc(..., alignment)preservesXMemVirtualAlloc's existingPAGES_2M(2 * MIB) /0behavior verbatim.XMemAllocDefault'sALLOC_32BITpath (xmem.rs:306-318), extracting1usize << (attributes >> ALIGNMENT_SHIFT & 0x1f)and passingif align > PAGE { align } else { 0 }matchesMEM_ADDRESS_REQUIREMENTS::Alignment(0 for 64 KiB granularity and powers of two above 64 KiB) while keepingXMemFreeDefault'sVirtualFree(..., MEM_RELEASE)symmetry intact.Verification (native Windows 11):
cargo xtask policyandcargo clippy --locked -p victory-hle --all-targets -- -D warnings(default and--all-features) pass cleanly.cargo test --locked -p victory-hle xmem::passes 15/15 (includingalloc_32bit_honours_alignments_above_64k).0, 1, 12, 16..=26(64 KiBthrough64 MiB) with 4 simultaneous live allocations across sizes1 Bto256 KiB(all< 4 GiB, properly aligned, writable, freed viaXMemFreeDefault/XMemFree, and re-allocated), extreme fields30/31(1 GiB/2 GiBwith no panic or UB), andXMemVirtualAllocwithPAGES_2M(2 MiBaligned).LGTM.
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.