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

Open
kalberts0089-hash wants to merge 1 commit from upstream-pr/2074 into main
kalberts0089-hash commented 2026-11-29 09:08:56 +00:00 (Migrated from github.com)

Imported from trustno1-coder/VIctory-NVIDIA. Originally posted by kalberts0089-hash on 2026-11-29T09:08:56Z.


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

<!-- greyfinch-sync:trustno1-coder/VIctory-NVIDIA:issue:5549281159 --> Imported from [trustno1-coder/VIctory-NVIDIA](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/2074). Originally posted by [kalberts0089-hash](https://github.com/kalberts0089-hash) on 2026-11-29T09:08:56Z. --- 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)
This pull request cannot be merged automatically due to conflicts.
Merge manually to resolve the conflicts.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin 'upstream-pr/2074:upstream-pr/2074'
git switch 'upstream-pr/2074'

Merge

Merge the changes and update on Forgejo.

Warning: The "Autodetect manual merge" setting is not enabled for this repository, you will have to mark this pull request as manually merged afterwards.

git switch 'main'
git merge --no-ff 'upstream-pr/2074'
git switch 'upstream-pr/2074'
git rebase 'main'
git switch 'main'
git merge --ff-only 'upstream-pr/2074'
git switch 'upstream-pr/2074'
git rebase 'main'
git switch 'main'
git merge --no-ff 'upstream-pr/2074'
git switch 'main'
git merge --squash 'upstream-pr/2074'
git switch 'main'
git merge --ff-only 'upstream-pr/2074'
git switch 'main'
git merge 'upstream-pr/2074'
git push origin 'main'
Sign in to join this conversation.
No reviewers
No labels
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.

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