Repository navigation
xmem: report allocations the host refuses - #538
Conversation
A refused XMemVirtualAlloc or XMemAllocDefault handed the title a null in silence, and the title then writes at null plus an offset, which reads like a title bug. In Marvisak#289 the faulting write is at 0x217800, the request's length 0x2173a0 rounded up to 2 KiB, so the base it built on was most likely such a null. At the commit limit, XMemVirtualAlloc now writes the same crashes.log report the physical-page commit writes since Marvisak#51 (the shared part is `commit_refused`); other refusals, and a host heap out of memory, are warnings. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
mercuryVM
left a comment
There was a problem hiding this comment.
Tested 65062e1 on Windows 11, RTX 5070, MSVC: cargo test --workspace --no-fail-fast passes (264 passed, 0 failed).
- Reporting a refused
VirtualAlloc2at the call that failed is a clear win. The reasoning about #289's0x217800= round-up(0x2173a0, 2 KiB) makes the "null + one block" reading convincing. Reusing the #51 commit-limit report forMEM_COMMITkeeps the paging-file advice in one place.last_os_error()is read right after the call, before anything else can overwrite it. - Nit: some titles probe for a free range by asking for a fixed base and handling the failure. Those refusals are expected, and now each one logs a
warn!. If logs turn out noisy, logging the first refusal per(kind, size)or demoting reserve-only failures todebug!would keep the signal. - The
PERFORMANCE_INFORMATIONstruct-update hunk is the same as #405, which is already in our fork. It merges cleanly.
AI-assisted (Claude Code).
…uses Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Independent verification & code review on Windows 11 Pro (build 26100, Rust
Diff review (
AI-assisted; synthetic tests only, no game files. |
catminou4
left a comment
There was a problem hiding this comment.
Static review only — victory-hle doesn't build on macOS (it depends on victory-gpu, which has the known host_resource cfg issue on non-Windows, fixed by #235/#523), so I could not compile or run the updated commit_limit_message tests here.
The change itself reads well: commit_refused centralizes the commit-limit reporting (crash log at the Windows commit limit, warning otherwise) and is now reused by both the virtual-memory path (XMemVirtualAlloc null result) and the physical-page path (commit), with the alloc-default heap OOM getting a warning too. The message wording gained the what parameter consistently, and the unit test updates match the new signature and assert the new wording.
One check for whoever runs Windows: the XMemVirtualAlloc early-return structure — the new at.is_null() block sits before the existing base.is_null() debug log, so a refused commit now warns and still falls through to the null-return path. That looks intended (report once, return null as before), but worth a smoke run of a commit-limit scenario.
Related to #289 (and the commit-limit reports of #23 / #51).
Why
If the host refuses
XMemVirtualAllocorXMemAllocDefault, the title gets a null and nothing is logged. A title that builds on that base then faults at null plus an offset, and the crash looks like a title bug.#289 looks like this case. The faulting
memsetwrites to0x217800, with length0x2173a0.0x2173a0rounded up to 2 KiB is exactly0x217800. So the destination is most likely a null base plus one aligned block, not a real pointer and not an APU device address. Which allocation returned the null can't be told from the report. With this change, the log would show it.What
XMemVirtualAllocreturning null:crashes.logreport that the physical-page commit has written since Report Windows commit-limit failures in crashes.log #51 (request size, system commit, the paging-file advice).XMemAllocDefaultwith the host heap out of memory: a warning with the size.commit_refused(len, what, error), now shared by both commit paths.commit_limit_messagetakeswhat("physical pages" or "virtual memory"). Its test now checks both wordings.field_reassign_with_defaulton the movedPERFORMANCE_INFORMATIONsetup is fixed.The OS error is read right after
VirtualAlloc2, before any logging can change it.Verification
cargo clippy -p victory-hle --tests --target x86_64-pc-windows-msvc: no warnings (one fewer thanmain).rustfmt: no diffs inxmem.rs.commit_limit_report_includes_request_and_system_commit) was type-checked but not executed.No game data used.
🤖 Generated with Claude Code