Skip to content

report apu heap allocations that fail - #1720

Merged
Marvisak merged 1 commit into
Marvisak:mainfrom
imjustprism:hle/apu-alloc-refusal-report
Nov 25, 2026
Merged

Marvisak merged 1 commit into
Marvisak:mainfrom
imjustprism:hle/apu-alloc-refusal-report

Conversation

@imjustprism

Copy link
Copy Markdown
Contributor

when the host allocator refuses an apu heap allocation, ApuAlloc returns E_OUTOFMEMORY and nothing is written anywhere. the title in #289 does not check that result and crashes a moment later on a write near null, so the crash log points at the title instead of at the cause. the refusal now goes to crashes.log with the size and the system commit, the same way the commit-limit report in xmem does, and a request that no device-address range fits gets a warning. both are reported by the caller after its locks are dropped. what the title sees does not change.

checked live: running the title in a job object with a 7.1 GB per-process commit cap reproduces #289, and crashes.log then starts with the refused allocation (about 401 MiB) and the commit numbers. only the report text has a unit test, the host allocator cannot be made to return null in one. clippy both ways, cargo test --workspace (343 passed) and xtask policy on windows 11.

#538 does the same for XMemVirtualAlloc and XMemAllocDefault and touches the same part of xmem.rs, so the two will conflict. #528 and #237 also touch ApuAlloc.

refs #289

Airamek added a commit to Airamek/VIctory that referenced this pull request Nov 24, 2026

@DenRakEiw DenRakEiw left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Verified locally merged onto origin/main (Windows 11 x64, Rust 1.98.1 MSVC):

  • cargo test -p victory-hle — 96 passed, 0 failed (including allocator_refusal_report_names_apu_heap_and_system_commit)
  • cargo clippy -p victory-hle --all-targets — 0 warnings
  • cargo xtask policy — ok

Clean diagnostics reporting failed APU heap allocations alongside system commit status, with unit test coverage. Looks good.

AI-assisted (Gemini 4 Neon).

@catminou4 catminou4 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Static review only: this crate is Windows-only (D3D12/windows_sys/Win32) — nothing compiles or runs on macOS; source review of the diff.

APU heap refusals are now reported with their cause: HeapRefusal::NoDeviceRange (size+align) warns, HostAllocator delegates to report_allocator_refusal which writes crashes.log — and report() is called with no lock held, which matters if the refusal path can run under the heap lock. Please confirm no caller holds the heap mutex when report() runs.

@imjustprism
imjustprism force-pushed the hle/apu-alloc-refusal-report branch 2 times, most recently from 88a3228 to 7a99074 Compare November 25, 2026 00:58
@imjustprism
imjustprism force-pushed the hle/apu-alloc-refusal-report branch from 7a99074 to bef186b Compare November 25, 2026 01:16

Marvisak commented Nov 25, 2026 •

Copy link
Copy Markdown
Owner

Automated triage for the maintainers.

Merge candidate. When the host allocator or the device-address range refuses an APU heap block, heap_alloc (audio.rs) now returns a HeapRefusal, and the callers (ApuAlloc, AcpHalAllocateShapeContexts) report it after dropping their locks. A host refusal goes to crashes.log through the new xmem::report_allocator_refusal, which shares its text with the existing commit-limit report. The HRESULT the title sees does not change. The lock order is fine: the HEAP guard is released on return, and CONTEXTS is dropped before report().

Update after your reply: confirmed, the branch now merges cleanly with main, so the #538 conflict is gone. CI passes.


Generated by Claude Code

@imjustprism

Copy link
Copy Markdown
Contributor Author

the description is out of date on one point: #538 is merged and this branch is rebased over it, so the xmem.rs conflict it mentions is gone. it merges clean into main at 940d32f and ci is green.

@StExpeditus

Copy link
Copy Markdown

Test report: RTX 5060 Ti (Blackwell), Windows 11 Pro 26200, driver 621.24. Branch at bef186b. cargo test --workspace --locked --no-fail-fast -> 694 passed, 5 failed, 10 ignored. The failures are the same 5 pre-existing NVIDIA 1M-view-heap-cap failures (also on main; see my reports on #2030 and #1940). Nothing introduced by this PR fails on this machine.

github-actions Bot added a commit to KevinPratap/VIctory that referenced this pull request Nov 25, 2026
@Marvisak
Marvisak merged commit deb05ab into Marvisak:main Nov 25, 2026
1 check passed
yyc160 added a commit to yyc160/VIctory that referenced this pull request Nov 26, 2026
Leave the allocator diagnostics tests together, including upstream Marvisak#1720. This moves the existing test unchanged so both additions merge without touching the allocator or rewriting the published PR branch.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants