XMem: keep allocation errors and report system commit #4318

Open
github-bot wants to merge 1 commit from github-bot/gh-4317 into main AGit
Owner

@⁠tyr0nsur on GitHub · 2026-11-30 18:50 UTC · original
tyr0nsur:codex/report-xmem-commit-headroom → main · +101 −36 · 1 files · 1 commits · open

Related to #4292.

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 VirtualAlloc or VirtualAlloc2 attempt 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 for ERROR_COMMITMENT_LIMIT and the existing retry and placement choices.

How it was tested

  • Windows 11, RTX 4060 8 GiB. Tests used synthetic allocations and no Series S/X profile or shader wave size.
  • On 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=1 passed (470 passed, 13 ignored). The staged asset-policy check passed.

Checked for overlap

  • Searched open PRs for the failure, paths and error handling. #3787 changes address placement and #3738 changes when pages are committed. This PR records the result of the existing calls.

Developed with Codex and reviewed with Claude Opus 5.5.

**@⁠tyr0nsur** on GitHub · 2026-11-30 18:50 UTC · [original](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/4317) `tyr0nsur:codex/report-xmem-commit-headroom` → `main` · +101 −36 · 1 files · 1 commits · open Related to #4292. ## 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 `VirtualAlloc` or `VirtualAlloc2` attempt 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 for `ERROR_COMMITMENT_LIMIT` and the existing retry and placement choices. ## How it was tested - Windows 11, RTX 4060 8 GiB. Tests used synthetic allocations and no Series S/X profile or shader wave size. - On `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=1` passed (470 passed, 13 ignored). The staged asset-policy check passed. ## Checked for overlap - [x] Searched open PRs for the failure, paths and error handling. #3787 changes address placement and #3738 changes when pages are committed. This PR records the result of the existing calls. Developed with Codex and reviewed with Claude Opus 5.5.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-30 18:52:39 +00:00
Author
Owner

@⁠babuakhil on GitHub · 2026-11-30 19:42 UTC · original

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 XMemVirtualAlloc and read GetLastError() right after, with three subscribers:

subscriber main this PR
none 87 87
a plain tracing_subscriber::fmt() writing to stderr 6 (ERROR_INVALID_HANDLE) 87
a sink that sets the last error to 88 (as in your test) 88 87

So with ordinary logging, main already hands the title the logger's error instead of Windows' refusal, and the SetLastError at 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 of XMemVirtualAlloc skips 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 is a_read_by_range_waits_only_for_a_remapping_that_meets_it, which fails the same way on main (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 in xmem.rs, the unwrap_or_default match in port_on, is on main too (line 1933 there, 1956 here).

**@⁠babuakhil** on GitHub · 2026-11-30 19:42 UTC · [original](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/4317#issuecomment-7289810124) 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 `XMemVirtualAlloc` and read `GetLastError()` right after, with three subscribers: | subscriber | `main` | this PR | |---|---|---| | none | 87 | 87 | | a plain `tracing_subscriber::fmt()` writing to stderr | **6** (`ERROR_INVALID_HANDLE`) | 87 | | a sink that sets the last error to 88 (as in your test) | 88 | 87 | So with ordinary logging, `main` already hands the title the logger's error instead of Windows' refusal, and the `SetLastError` at 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 of `XMemVirtualAlloc` skips 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 is `a_read_by_range_waits_only_for_a_remapping_that_meets_it`, which fails the same way on `main` (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 in `xmem.rs`, the `unwrap_or_default` match in `port_on`, is on `main` too (line 1933 there, 1956 here).
github-bot force-pushed github-bot/gh-4317 from 2633ccb9d1 to b992a995b5 2026-12-01 00:05:05 +00:00 Compare
This pull request can be merged automatically.
This branch is out-of-date with the base branch
You are not authorized to merge this pull request.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin '+refs/pull/4318/head:github-bot/gh-4317'
git switch 'github-bot/gh-4317'

Merge

Merge the changes and update on Forgejo.
git switch 'main'
git merge --no-ff 'github-bot/gh-4317'
git switch 'github-bot/gh-4317'
git rebase 'main'
git switch 'main'
git merge --ff-only 'github-bot/gh-4317'
git switch 'github-bot/gh-4317'
git rebase 'main'
git switch 'main'
git merge --no-ff 'github-bot/gh-4317'
git switch 'main'
git merge --squash 'github-bot/gh-4317'
git switch 'main'
git merge --ff-only 'github-bot/gh-4317'
git switch 'main'
git merge 'github-bot/gh-4317'
git push origin 'main'
This discussion has been locked. Commenting is limited to contributors.
No reviewers
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
github/trustno1-coder--VIctory-NVIDIA!4318
No description provided.