XMem: keep allocation errors and report system commit #4317
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/4317"
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?
Imported from trustno1-coder/VIctory-NVIDIA. Originally posted by tyr0nsur on 2026-11-30T18:50:04Z.
Related to #4291.
What it changes
The report showed Win32 error 8 while the title's window still had a large free gap. The tester could start with the same profile after increasing the Windows paging file. A play log with the system commit figures next to the failed allocation would help distinguish this pattern from a refusal caused by limited address space.
Capture the result of each
VirtualAllocorVirtualAlloc2attempt before probing the window, trimming spare buffers or logging. If a retry fails, use its error. Return the final failure code to the title. For memory refusals, log the system commit in use and its limit when Windows supplies the figures. Preserve the existing crash-log path forERROR_COMMITMENT_LIMITand the existing retry and placement choices.How it was tested
e1251c31, a zero-byte commit set Win32 error 87, and the logging path returned 88 after a synthetic log sink changed the thread's error. With this patch the regression keeps 87.cargo test -p victory-hle --locked --lib --quiet -- --test-threads=1passed (470 passed, 13 ignored). The staged asset-policy check passed.Checked for overlap
Developed with Codex and reviewed with Claude Opus 5.5.
Imported from trustno1-coder/VIctory-NVIDIA. Originally posted by babuakhil on 2026-11-30T19:42:17Z.
Checked on Windows 11 (Rust 1.98.1, pinned), on
main(e1251c31), which this is based on. Not tested in the game.The lost error is real without the synthetic sink. A throwaway test (not part of this PR) made the same refused zero-byte commit through
XMemVirtualAllocand readGetLastError()right after, with three subscribers:maintracing_subscriber::fmt()writing to stderrERROR_INVALID_HANDLE)So with ordinary logging,
mainalready hands the title the logger's error instead of Windows' refusal, and theSetLastErrorat the end fixes that. That's the part that matters for a title deciding what to do after a null. I also checked that no path out ofXMemVirtualAllocskips it: the only early return hands back the title's own placeholder, not a failure.cargo test -p victory-hle --lib modules::xmem: 50 passed and 1 failed, two runs out of two. The failure isa_read_by_range_waits_only_for_a_remapping_that_meets_it, which fails the same way onmain(49 passed, 1 failed, two runs out of two) and passes alone on both, so it's the timing test you mentioned, not this change. Clippy's only note inxmem.rs, theunwrap_or_defaultmatch inport_on, is onmaintoo (line 1933 there, 1956 here).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.Warning: The "Autodetect manual merge" setting is not enabled for this repository, you will have to mark this pull request as manually merged afterwards.