Loader: an allocation the system refuses is written to crashes.log #2074

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

@⁠kalberts0089-hash on GitHub · 2026-11-29 09:08 UTC · original
kalberts0089-hash:alloc-failure-log → main · +450 −13 · 9 files · 1 commits · open

Part of #1956

What it changes

When the allocator returns null, Rust prints "memory allocation of N bytes failed" to the console and fails fast (0xc0000409). No exception handler sees that, so crashes.log stayed empty and the play log just stopped.

The process's allocator is now the system's behind victory_core::heap::Heap. Before the null goes back, it appends an entry to crashes.log with the size and alignment that were asked for, the commit left, the commit limit and the free physical memory. Writing the entry allocates nothing: the text is built on the stack and written through a handle that log_crashes_to opens at start. A caller that handles the null itself (try_reserve) gets an entry too. At most 16 entries are written per process.

There is one global allocator in every build. Plain builds declare Heap in victory-gpu, and diagnostics builds keep copystat's Counting, which now calls Heap instead of System. docs/windows-memory.md says where to find the new entry.

How it was tested

  • GPU and profile: RTX 4070 Ti 12 GB, Windows 11 build 26300. The game was not run.
  • New tests: in a child process, a refused allocation's entry lands in the crash log, both through Heap directly and through log_crashes_to. The entry fits its stack buffer when every number is at its largest, and building it allocates nothing.
  • cargo test passed for the crates it touches: yes (victory-core, victory-loader, victory-gpu with --test-threads=1)
  • cargo build --release -p victory passes. On current main the diagnostics build fails in code this PR does not touch (mb in copystat, timing in host). With #2048 applied on top, the diagnostics build passes. Clippy shows no new warnings compared with main, in plain or diagnostics builds.

Checked for overlap

  • I searched the open pull requests for the same issue and for the files this touches. Related: #1487 (mimalloc) also replaces the global allocator and changes Counting, so whichever PR lands second needs a small rebase. #730 and #537 also change Counting or its gating.

🤖 Generated with Claude Code

**@⁠kalberts0089-hash** on GitHub · 2026-11-29 09:08 UTC · [original](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/2074) `kalberts0089-hash:alloc-failure-log` → `main` · +450 −13 · 9 files · 1 commits · open Part of #1956 ## What it changes When the allocator returns null, Rust prints "memory allocation of N bytes failed" to the console and fails fast (0xc0000409). No exception handler sees that, so `crashes.log` stayed empty and the play log just stopped. The process's allocator is now the system's behind `victory_core::heap::Heap`. Before the null goes back, it appends an entry to `crashes.log` with the size and alignment that were asked for, the commit left, the commit limit and the free physical memory. Writing the entry allocates nothing: the text is built on the stack and written through a handle that `log_crashes_to` opens at start. A caller that handles the null itself (`try_reserve`) gets an entry too. At most 16 entries are written per process. There is one global allocator in every build. Plain builds declare `Heap` in victory-gpu, and diagnostics builds keep copystat's `Counting`, which now calls `Heap` instead of `System`. `docs/windows-memory.md` says where to find the new entry. ## How it was tested - GPU and profile: RTX 4070 Ti 12 GB, Windows 11 build 26300. The game was not run. - New tests: in a child process, a refused allocation's entry lands in the crash log, both through `Heap` directly and through `log_crashes_to`. The entry fits its stack buffer when every number is at its largest, and building it allocates nothing. - `cargo test` passed for the crates it touches: yes (victory-core, victory-loader, victory-gpu with `--test-threads=1`) - `cargo build --release -p victory` passes. On current main the diagnostics build fails in code this PR does not touch (`mb` in copystat, `timing` in host). With #2048 applied on top, the diagnostics build passes. Clippy shows no new warnings compared with main, in plain or diagnostics builds. ## Checked for overlap - [x] I searched the open pull requests for the same issue and for the files this touches. Related: #1487 (mimalloc) also replaces the global allocator and changes `Counting`, so whichever PR lands second needs a small rebase. #730 and #537 also change `Counting` or its gating. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
Rust ends the process on a null from the allocator: it prints "memory
allocation of N bytes failed" to the console and fails fast (0xc0000409),
which no exception handler or filter sees, so crashes.log had nothing and
the play log just stopped (#1956). The process's allocator is now the
system's behind victory_core::heap::Heap, which first appends an entry to
crashes.log: the size and alignment asked for, the commit left and the
commit limit, and the physical memory free. It allocates nothing for it:
the text is made on the stack and written through a handle that
log_crashes_to opens. The null then goes back as before. A caller that
takes the null itself (try_reserve) gets an entry too.

victory-gpu declares it the global allocator in plain builds; in
diagnostics builds copystat's Counting stands in front of it instead, so
there is one either way. Heap's calls are inlined like System's and the
entry is written out of line. At most 16 entries are written per process.
docs/windows-memory.md names the entry beside the console's line.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-29 09:12:10 +00:00
This pull request has changes conflicting with the target branch.
  • crates/victory-gpu/src/copystat.rs
View command line instructions

Manual merge helper

Use this merge commit message when completing the merge manually.

Checkout

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

Merge

Merge the changes and update on Forgejo.
git switch 'main'
git merge --no-ff 'github-bot/gh-2074'
git switch 'github-bot/gh-2074'
git rebase 'main'
git switch 'main'
git merge --ff-only 'github-bot/gh-2074'
git switch 'github-bot/gh-2074'
git rebase 'main'
git switch 'main'
git merge --no-ff 'github-bot/gh-2074'
git switch 'main'
git merge --squash 'github-bot/gh-2074'
git switch 'main'
git merge --ff-only 'github-bot/gh-2074'
git switch 'main'
git merge 'github-bot/gh-2074'
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!2074
No description provided.