xmem: 32-bit XMemAllocDefault blocks ignore alignments above 64 KiB #2183
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#2183
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
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
What happens
XMemAllocDefault(behindXMemAllocwhen the title installs no hooks) reads the alignment fromattributes(log2 in 5 bits at 24) for host-heap blocks, but its 32-bit branch (attributes & ALLOC_32BIT) drops it:Without
PAGES_2Min the kind,XMemVirtualAllocpassesMEM_ADDRESS_REQUIREMENTS::Alignment = 0, i.e. the 64 KiB allocation granularity. A 32-bit block asked for at 128 KiB, 256 KiB, 1 MiB or 2 MiB can come back only 64 KiB-aligned (0x10000for a 128 KiB request in a quick synthetic run under Wine).Expected
The module's own header says what constrains addresses is honoured: "what constrains addresses (alignment, 2 MiB pages, address-bit limits) is honoured." A 32-bit block should get the alignment the attributes ask for, as a host-heap block does.
MEM_ADDRESS_REQUIREMENTStakes it directly ("Specifies power-of-2 alignment. Specifying 0 aligns the returned address on the system allocation granularity. If nonzero, this value must be greater than or equal to the system allocation granularity." — https://learn.microsoft.com/en-us/windows/win32/api/winnt/ns-winnt-mem_address_requirements).Where
crates/victory-hle/src/modules/xmem.rs,XMemAllocDefault. The title importsxmem.dll!XMemAlloc; whether it asks for 32-bit blocks above 64 KiB alignment is not measured.AI-assisted (Gemini 4 Neon found it, Claude Code reviewed and verified it); synthetic test only, no game data.
@Marvisak on GitHub · 2026-11-25 15:49 UTC · original · edited 2026-11-26 06:48 UTC
Automated triage for the maintainers.
Confirmed on
main: incrates/victory-hle/src/modules/xmem.rs,XMemAllocDefault'sALLOC_32BITbranch callsXMemVirtualAllocwithout the attributes' alignment, andXMemVirtualAllocsets a non-zeroMEM_ADDRESS_REQUIREMENTS::Alignmentonly for 2 MiB pages. A 32-bit block therefore gets 64 KiB alignment at most.Open PRs addressing it: #2184 and #2529. New since the last triage: a comparison on an RTX 4070 against
main63bcca4found both tests fail onmainand pass with either fix, both merge cleanly, and the fixes are functionally equivalent (#2529 additionally returns null whensize + alignoverflows). The choice between them is for the maintainers.Generated by Claude Code
@pawrenity on GitHub · 2026-11-26 04:12 UTC · original
Comparative verification: #2184 and #2529
I checked both open PRs against current
main(63bcca4) on NVIDIA GeForce RTX 4070, Windows 11 (x86_64-pc-windows-msvc).main(test only)-D warnings(victory-hle, all targets)main8954790victory-hle144/144field 0x11: … is not 131072-byte aligned)7a37340victory-hle153/153What each fix does. Both fixes pass the attribute's alignment to
MEM_ADDRESS_REQUIREMENTS::Alignmentonly when it is above 64 KiB.XMemVirtualAllockeeps its old behaviour in both. #2184 splits outvirtual_alloc(…, alignment)and has the caller choose the value. #2529 addsvirtual_alloc_aligned(…, align), which makes the> 0x10000choice itself, and moveslayout()ahead of the 32-bit branch. That means a 32-bit request whosesize + alignoverflowsLayoutnow returns null before reachingVirtualAlloc2. I don't see a practical effect from this.Tests. I ran each test with only its test hunk on
main, and it failed every time. #2529's test holds one block per alignment, so in principle it could pass by chance. #2184's test holds four live blocks per alignment, checks that they are writable, and also covers alignments at or below 64 KiB.Recommendation. The two fixes are functionally equivalent, and I found no defect in either one. #2184 is the better one to merge. It is a single commit, its test is stronger, and it came first. #2529 is a duplicate. Its branch also carries two merge commits from the fork.
No title run. Synthetic tests only.
AI-assisted (Claude Code).