xmem: report allocations the host refuses #538
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/538"
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 Marvisak/VIctory. Originally posted by coderanonymus on 2026-11-24T04:39:23Z.
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 #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
Imported from Marvisak/VIctory. Originally posted by mercuryVM on 2026-11-24T08:55:46Z.
Review: APPROVED
Tested
65062e1on Windows 11, RTX 5070, MSVC:cargo test --workspace --no-fail-fastpasses (264 passed, 0 failed).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.warn!. If logs turn out noisy, logging the first refusal per(kind, size)or demoting reserve-only failures todebug!would keep the signal.PERFORMANCE_INFORMATIONstruct-update hunk is the same as #405, which is already in our fork. It merges cleanly.AI-assisted (Claude Code).
Imported from Marvisak/VIctory. Originally posted by geiyiliyabumo on 2026-11-24T11:47:29Z.
Independent verification & code review on Windows 11 Pro (build 26100, Rust
1.98.1), cleanly merged ontomain(ffe310e):cargo xtask policy: PASS (154 files ok)cargo clippy -p victory-hle --all-targets --locked -- -D warnings: PASScargo clippy -p victory-hle --all-targets --features diagnostics --locked -- -D warnings: PASScargo test -p victory-hle --locked: 94 passed + 1 integration test (no_dll_planting), 0 failed (including updatedcommit_limit_report_includes_request_and_system_commit)Diff review (
crates/victory-hle/src/modules/xmem.rs): clean, minimal, and very useful diagnostics for OOM/commit-limit failures.XMemVirtualAlloc, callingcommit_refused(K32GetPerformanceInfo+log_crashfile I/O) ortracing::warn!before returningNULLcan overwrite the thread's Win32 last-error code; restoringSetLastErrorfromerror.raw_os_error()before returningatwould preserveGetLastError()for title callers that inspect it after a failed allocation.AI-assisted; synthetic tests only, no game files.
Imported from Marvisak/VIctory. Originally posted by catminou4 on 2026-11-24T12:44:25Z.
Review: COMMENTED
Static review only —
victory-hledoesn't build on macOS (it depends onvictory-gpu, which has the knownhost_resourcecfg issue on non-Windows, fixed by #235/#523), so I could not compile or run the updatedcommit_limit_messagetests here.The change itself reads well:
commit_refusedcentralizes the commit-limit reporting (crash log at the Windows commit limit, warning otherwise) and is now reused by both the virtual-memory path (XMemVirtualAllocnull result) and the physical-page path (commit), with the alloc-default heap OOM getting a warning too. The message wording gained thewhatparameter consistently, and the unit test updates match the new signature and assert the new wording.One check for whoever runs Windows: the
XMemVirtualAllocearly-return structure — the newat.is_null()block sits before the existingbase.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.