fix(vk): at Windows' commit limit the renderer's C++ allocations wait for memory, then say out of memory #1291

Merged
HumanBean merged 2 commits from HumanBean/Longshot:push-lvooylormqzq into main 2026-11-17 01:04:23 +00:00
Owner

Type: fix · Risk: medium · Tested on: Linux, RTX 3090 · Needs: Windows, any GPU

Why

When Windows runs out of memory to hand out (RAM plus the page file full, its "commit limit"), the renderer could not get memory for one of its own C++ objects and the game closed at once with "An unexpected error". There was no wait for memory to come back and no out-of-memory notice. The crash record says exception: 0x20474343: a C++ exception (std::bad_alloc) that nothing caught in longshot_vk.dll. Fourteen player reports in two days were this crash (16 GB and 32 GB PCs, rc.4 to rc.5), now closed as duplicates of #1280.

#341 made the host's own C allocations wait at the limit and then say out of memory (#333). The renderer's C++ allocations don't go through that path, so they still crashed like this. With this PR they're handled the same way: wait for memory, and if none comes back, show the out-of-memory notice and stop.

The growth that brings a PC to the limit is #388's. This PR is only about how the game ends there.

How to reproduce

Seen on: Windows 11, RTX 3050 6 GB laptop, 16 GB RAM (#1260); also RTX 4060 with 32 GB (#1101), RTX 3060 Ti with 16 GB (#1217), and 11 more in #1280
Settings and switches: defaults are enough; any setting that uses more memory gets there sooner
Steps: play until the PC reaches its commit limit (the log says commit limit near: … of commit left), from 3 minutes to over an hour of play in the reports. On a PC with more memory, this PR's HOS_TEST_ALLOC_REFUSE=renderer reaches the same path (main doesn't have it).
Expected: the game waits for memory, then says it is out of memory (log line and notice) before it stops.
Actual: CRASH: exception 0x20474343 … at KERNELBASE.dll+0xc569a, "An unexpected error", no notice.

What changed

The renderer now has a C++ new_handler. When an allocation is refused, it waits 50 ms and lets the allocation try again, for up to 5 s, as #341's host allocations do. Then it stops through the host's out-of-memory line and notice. Allocations that already have a fallback for a refusal keep getting their null at once.

  • vk: new_refused() in gpu/vk/vk_main.cpp, installed by mkwvk_init with std::set_new_handler:
    • libc++'s and libstdc++'s operator new (plain, aligned, array) call it each time malloc refuses, and try again when it returns.
    • The 5 s are counted per thread. A refusal more than 250 ms after this thread's last try counts as a new one and gets a whole 5 s.
    • One log line at the start of a wait (the first 8 a run).
    • After 5 s: the host's out_of_memory, which does not return. A host older than version 28 has no out_of_memory, so the renderer throws std::bad_alloc as before.
  • vk: NewNothrow (gpu/vk/vk_new.h, new). Inside its scope the handler throws at once, which the C++ libraries' nothrow new turns into its null. It wraps the three nothrow allocations that have a fallback: the recorder's ring and its arena's chunks (gpu/vk/vk_recorder.h) and a capture's staging block (gpu/vk/vk_memory.cpp). It also wraps the shader translation (gpu/vk/vk_shader.cpp, both try blocks): a bad shader can ask for a size no PC has, and that fails the one program, as before.
  • vk/host interface: MkwVkHost.out_of_memory(const char *what), appended after main_thread_times. MKWVK_API_VERSION 27 → 28. The host's side is host_out_of_memory in host/rx_backend.c.
  • hos: hos_alloc_gave_up(n, what) in host/mkw_glue.c (declared in host/hos.h) is the end of #341's hos_alloc_failed, split out: the line, the notice (waited for), the fatal. n 0 means the size is not known, as for the renderer's allocations, and the lines then give no byte count. #341's messages are unchanged when the size is known.
  • Test switch: HOS_TEST_ALLOC_REFUSE=renderer (#341's switch, a new label). At the replay's 600th present, new_refuse_test() asks for one allocation of 1 PB, which no PC can give, to show what a player sees at the limit.
  • tests:
    • tests/test_renderer_new_handler.py (new) with tests/renderer_new_handler_test.cpp compiles the real new_refused cut from vk_main.cpp. Its refusals are real: 1 PB asked of the C++ library's own operator new.
    • It checks 5 s of tries and then the host's stop for plain, aligned and array new; the per-thread budget and its reset; nothrow forms in and out of a NewNothrow scope; and an old host or none.
    • By text it also checks that mkwvk_init installs the handler after it has the host, and that every std::nothrow in gpu/vk/ is in a scope.
    • tests/test_host_alloc_wait.py cuts hos_alloc_gave_up too and has three new cases: no size, not the limit, and the test switch.
    • tests/test_audio_output_devices.py takes version 28's slot. tests/test_recorder_sync.py copies vk_new.h beside the recorder.
  • docs: docs/development.md, the HOS_TEST_ALLOC_REFUSE row and API version 28 in the host interface paragraph.

Measurements

Verdict: passes in the game. A refused renderer allocation waited 5.0 s (18.37 s to 23.38 s) on the host thread (the thread in the player reports), then gave the out-of-memory line and fatal instead of the uncaught exception. Nothing to measure for speed: the handler runs only when an allocation is refused.

Hardware: Linux (CachyOS), RTX 3090 (NVIDIA 620.70.06), Ryzen 9 7900X, 32 GB RAM
Scene: boot to the title screen, headless (HOS_HEADLESS=1: the notice is the log line only)
Method: the game's log, with each line stamped with its arrival time; two runs, one before and one after the review's fixes, the same both times (5.0 s). The runs were on this branch over main 8e9cfc3a. The rebase onto 181571bd brought in one commit, a script the game doesn't run
How to reproduce: HOS_TEST_ALLOC_REFUSE=renderer HOS_HEADLESS=1 ./longshot in a runtime of this branch (scripts/dev_build.py rt)

Before: main @ 8e9cfc3a After: this PR @ efd580ac
A refused C++ allocation in the renderer uncaught std::bad_alloc, exception 0x20474343 (the player reports in #1280) 5.0 s of tries, the out-of-memory line, FATAL: out of memory (RAM plus swap): the renderer's C++ allocations
   0.675 [hos MainThread] vk: driver: NVIDIA 620.70.06
  18.373 [hos host] vk: HOS_TEST_ALLOC_REFUSE: one C++ allocation of 1 PB, refused on any PC, to see what a player sees at the commit limit
  18.373 [hos host] vk: a C++ allocation refused (at the commit limit?): tried again for up to 5 s
  23.375 [hos host] mem: the renderer's C++ allocations: still refused after 5 s at the commit limit (50467 MB of commit left)
  23.375 [hos host] mem: out of memory (RAM and swap): close other programs, or add swap
  23.397 [hos host] FATAL: out of memory (RAM plus swap): the renderer's C++ allocations

Flags and settings

One new value for an existing test switch, off when unset.

Flag What it is Before this PR After this PR Effect Helps / doesn't help / untested Recommendation
HOS_TEST_ALLOC_REFUSE=renderer #341's test switch, a new label unset; refused only the host's labels unset asks for one 1 PB allocation at the 600th present, so the wait, the notice and the stop can be seen a test off: only for testing

Testing

Tested:

  • In the game on Linux (RTX 3090), headless, with HOS_TEST_ALLOC_REFUSE=renderer: the run above.
  • This branch built as a pack over main 8e9cfc3a (scripts/dev_build.py pack): the Linux game and longshot_vk.so compiled and linked.
  • A second agent reviewed the diff and the tests cold. From its findings: the fixture's new (std::nothrow)[] case keeps its result in a volatile (clang may fold a new compared with null alone), and the shader translation went into a NewNothrow scope. It found the handler right under both libraries (plain, aligned, array, nothrow), with nothing re-entering it, and the tests failing on main for the bug's reason.

Not tested:

  • No game-free check was run on this PC, by the owner's rule, including the new test failing on main and passing here: left to CI.
  • Not built for Windows (llvm-mingw, libc++).
  • Not run at a real commit limit.
  • The notice window itself wasn't seen (headless). It is #341's code, unchanged.

Must be tested:

  • Windows, any GPU: set HOS_TEST_ALLOC_REFUSE=renderer and start the game, expecting at about 10 s of the title a 5 s pause, then the "Longshot: out of memory" notice, and the game stopping once it is closed. longshot_log.txt should say mem: the renderer's C++ allocations: still refused after 5 s and have no CRASH: exception 0x20474343. (Test Farm: @Beanstalk windows, HOS_TEST_ALLOC_REFUSE=renderer in longshot_env.txt, the title screen)
  • Linux and Windows, game-free: python -I -B tests/run_all.py, test_renderer_new_handler and test_host_alloc_wait above all, expecting them to pass, and the new test to fail on main with "mkwvk_init installs no new_handler" (by hand or CI: the run's table; not run on this PC by its owner's rule)

Risks

What could break:

  • Everything the renderer allocates with new goes through the handler when malloc refuses. A refusal that used to throw and be caught now waits up to 5 s and stops the game with the out-of-memory notice. One case: a background job's std::bad_alloc was caught by run_guarded (gpu/vk/vk_jobs.cpp), logged, and the game went on.
  • Not in a scope, on purpose (written in vk_new.h): the C++ library's own nothrow buffers (std::stable_sort, std::inplace_merge) and the renderer's other catch blocks around allocations (the caches' inserts, thread starts). At the limit they now wait with every other allocation, then stop with the notice. Before, the unwind to them often failed there anyway (0xc00000ff after the throw in #1217, #1182 and #981).
  • The 5 s are counted per thread, from the first refusal. A thread refused again within 250 ms of its last try goes on counting the same 5 s, so under heavy thrashing it can stop while memory is still coming back.
  • The handler waits on the refused thread, holding whatever locks it holds. The hang watches (10 s or more) don't fire in those 5 s.
  • With no size known, a refusal with over 1 GB of commit left is "not the limit": a fatal that says so, with no notice (as #341 does for a size gone wrong).
  • A nothrow new added later outside a NewNothrow scope waits and stops too, instead of getting its null. The new test's text check names any such line that writes std::nothrow.

Turning it off: revert the commits.

Compatibility: the vk ABI, MKWVK_API_VERSION 27 → 28: the host and the renderer must come from one build, as always. Saves, settings and caches don't change.

Issues

Fixes #1280
See #333, #341, #388

Checklist

Everyone

  • One topic.
  • The title is a Conventional Commit (type(scope): description) of the status line's type.
  • Why gives the reason plainly and links the issues that fit (the tracker searched).
  • Measurements has a verdict, or one line saying why there is nothing to measure.
  • Testing names what was tested, what wasn't, and what must still be tested, where and how.
  • Rebased on current main.
  • python -I -B tests/run_all.py passes (any failure that also fails on main is named). Not run on this PC (the owner's rule): left to CI.
  • No game files, dumps, build output or generated files.
  • third_party/ untouched (a new folder with a PROVENANCE.md instead).
  • The license is OK: GPL-3.0-or-later, nothing incompatible and nothing decompiled.

When it applies

  • AI assistance recorded with Assisted-by: / Co-Authored-By: trailers.
  • Switches documented (docs/development.md; the README for a menu row) and shipped at their recommended value.
  • MKWVK_API_VERSION bumped (gpu/vk/vk_api.h's MkwVkHost or MkwVkRenderer changed).
  • A game-free test added for the fix, failing on main and passing here. Added, not run here: CI.
  • A check under tests/ that reads changed source updated in this PR, not weakened.
  • Host code builds on both Windows (llvm-mingw) and Linux, with UTF-8 paths. Built on Linux only: Windows needs the Test Farm or CI.
  • Docs updated.

🤖 Generated with Claude Code

**Type:** fix · **Risk:** medium · **Tested on:** Linux, RTX 3090 · **Needs:** Windows, any GPU ## Why When Windows runs out of memory to hand out (RAM plus the page file full, its "commit limit"), the renderer could not get memory for one of its own C++ objects and the game closed at once with "An unexpected error". There was no wait for memory to come back and no out-of-memory notice. The crash record says `exception: 0x20474343`: a C++ exception (`std::bad_alloc`) that nothing caught in `longshot_vk.dll`. Fourteen player reports in two days were this crash (16 GB and 32 GB PCs, rc.4 to rc.5), now closed as duplicates of #1280. #341 made the host's own C allocations wait at the limit and then say out of memory (#333). The renderer's C++ allocations don't go through that path, so they still crashed like this. With this PR they're handled the same way: wait for memory, and if none comes back, show the out-of-memory notice and stop. The growth that brings a PC to the limit is #388's. This PR is only about how the game ends there. ## How to reproduce **Seen on:** Windows 11, RTX 3050 6 GB laptop, 16 GB RAM (#1260); also RTX 4060 with 32 GB (#1101), RTX 3060 Ti with 16 GB (#1217), and 11 more in #1280 **Settings and switches:** defaults are enough; any setting that uses more memory gets there sooner **Steps:** play until the PC reaches its commit limit (the log says `commit limit near: … of commit left`), from 3 minutes to over an hour of play in the reports. On a PC with more memory, this PR's `HOS_TEST_ALLOC_REFUSE=renderer` reaches the same path (`main` doesn't have it). **Expected:** the game waits for memory, then says it is out of memory (log line and notice) before it stops. **Actual:** `CRASH: exception 0x20474343 … at KERNELBASE.dll+0xc569a`, "An unexpected error", no notice. ## What changed The renderer now has a C++ `new_handler`. When an allocation is refused, it waits 50 ms and lets the allocation try again, for up to 5 s, as #341's host allocations do. Then it stops through the host's out-of-memory line and notice. Allocations that already have a fallback for a refusal keep getting their null at once. - vk: `new_refused()` in `gpu/vk/vk_main.cpp`, installed by `mkwvk_init` with `std::set_new_handler`: - libc++'s and libstdc++'s `operator new` (plain, aligned, array) call it each time `malloc` refuses, and try again when it returns. - The 5 s are counted per thread. A refusal more than 250 ms after this thread's last try counts as a new one and gets a whole 5 s. - One log line at the start of a wait (the first 8 a run). - After 5 s: the host's `out_of_memory`, which does not return. A host older than version 28 has no `out_of_memory`, so the renderer throws `std::bad_alloc` as before. - vk: `NewNothrow` (`gpu/vk/vk_new.h`, new). Inside its scope the handler throws at once, which the C++ libraries' nothrow `new` turns into its null. It wraps the three nothrow allocations that have a fallback: the recorder's ring and its arena's chunks (`gpu/vk/vk_recorder.h`) and a capture's staging block (`gpu/vk/vk_memory.cpp`). It also wraps the shader translation (`gpu/vk/vk_shader.cpp`, both `try` blocks): a bad shader can ask for a size no PC has, and that fails the one program, as before. - vk/host interface: `MkwVkHost.out_of_memory(const char *what)`, appended after `main_thread_times`. **`MKWVK_API_VERSION` 27 → 28.** The host's side is `host_out_of_memory` in `host/rx_backend.c`. - hos: `hos_alloc_gave_up(n, what)` in `host/mkw_glue.c` (declared in `host/hos.h`) is the end of #341's `hos_alloc_failed`, split out: the line, the notice (waited for), the fatal. `n` 0 means the size is not known, as for the renderer's allocations, and the lines then give no byte count. #341's messages are unchanged when the size is known. - Test switch: `HOS_TEST_ALLOC_REFUSE=renderer` (#341's switch, a new label). At the replay's 600th present, `new_refuse_test()` asks for one allocation of 1 PB, which no PC can give, to show what a player sees at the limit. - tests: - `tests/test_renderer_new_handler.py` (new) with `tests/renderer_new_handler_test.cpp` compiles the real `new_refused` cut from `vk_main.cpp`. Its refusals are real: 1 PB asked of the C++ library's own `operator new`. - It checks 5 s of tries and then the host's stop for plain, aligned and array `new`; the per-thread budget and its reset; nothrow forms in and out of a `NewNothrow` scope; and an old host or none. - By text it also checks that `mkwvk_init` installs the handler after it has the host, and that every `std::nothrow` in `gpu/vk/` is in a scope. - `tests/test_host_alloc_wait.py` cuts `hos_alloc_gave_up` too and has three new cases: no size, not the limit, and the test switch. - `tests/test_audio_output_devices.py` takes version 28's slot. `tests/test_recorder_sync.py` copies `vk_new.h` beside the recorder. - docs: `docs/development.md`, the `HOS_TEST_ALLOC_REFUSE` row and API version 28 in the host interface paragraph. ## Measurements **Verdict:** passes in the game. A refused renderer allocation waited 5.0 s (18.37 s to 23.38 s) on the `host` thread (the thread in the player reports), then gave the out-of-memory line and fatal instead of the uncaught exception. Nothing to measure for speed: the handler runs only when an allocation is refused. Hardware: Linux (CachyOS), RTX 3090 (NVIDIA 620.70.06), Ryzen 9 7900X, 32 GB RAM Scene: boot to the title screen, headless (`HOS_HEADLESS=1`: the notice is the log line only) Method: the game's log, with each line stamped with its arrival time; two runs, one before and one after the review's fixes, the same both times (5.0 s). The runs were on this branch over `main` 8e9cfc3a. The rebase onto 181571bd brought in one commit, a script the game doesn't run How to reproduce: `HOS_TEST_ALLOC_REFUSE=renderer HOS_HEADLESS=1 ./longshot` in a runtime of this branch (`scripts/dev_build.py rt`) | | Before: main @ 8e9cfc3a | After: this PR @ efd580ac | |---|---|---| | A refused C++ allocation in the renderer | uncaught `std::bad_alloc`, exception 0x20474343 (the player reports in #1280) | 5.0 s of tries, the out-of-memory line, `FATAL: out of memory (RAM plus swap): the renderer's C++ allocations` | ``` 0.675 [hos MainThread] vk: driver: NVIDIA 620.70.06 18.373 [hos host] vk: HOS_TEST_ALLOC_REFUSE: one C++ allocation of 1 PB, refused on any PC, to see what a player sees at the commit limit 18.373 [hos host] vk: a C++ allocation refused (at the commit limit?): tried again for up to 5 s 23.375 [hos host] mem: the renderer's C++ allocations: still refused after 5 s at the commit limit (50467 MB of commit left) 23.375 [hos host] mem: out of memory (RAM and swap): close other programs, or add swap 23.397 [hos host] FATAL: out of memory (RAM plus swap): the renderer's C++ allocations ``` ### Flags and settings One new value for an existing test switch, off when unset. | Flag | What it is | Before this PR | After this PR | Effect | Helps / doesn't help / untested | Recommendation | |---|---|---|---|---|---|---| | `HOS_TEST_ALLOC_REFUSE=renderer` | #341's test switch, a new label | unset; refused only the host's labels | unset | asks for one 1 PB allocation at the 600th present, so the wait, the notice and the stop can be seen | a test | off: only for testing | ## Testing **Tested:** - In the game on Linux (RTX 3090), headless, with `HOS_TEST_ALLOC_REFUSE=renderer`: the run above. - This branch built as a pack over `main` 8e9cfc3a (`scripts/dev_build.py pack`): the Linux game and `longshot_vk.so` compiled and linked. - A second agent reviewed the diff and the tests cold. From its findings: the fixture's `new (std::nothrow)[]` case keeps its result in a volatile (clang may fold a `new` compared with null alone), and the shader translation went into a `NewNothrow` scope. It found the handler right under both libraries (plain, aligned, array, nothrow), with nothing re-entering it, and the tests failing on `main` for the bug's reason. **Not tested:** - No game-free check was run on this PC, by the owner's rule, including the new test failing on `main` and passing here: left to CI. - Not built for Windows (llvm-mingw, libc++). - Not run at a real commit limit. - The notice window itself wasn't seen (headless). It is #341's code, unchanged. **Must be tested:** - Windows, any GPU: set `HOS_TEST_ALLOC_REFUSE=renderer` and start the game, expecting at about 10 s of the title a 5 s pause, then the "Longshot: out of memory" notice, and the game stopping once it is closed. `longshot_log.txt` should say `mem: the renderer's C++ allocations: still refused after 5 s` and have no `CRASH: exception 0x20474343`. (Test Farm: @Beanstalk windows, HOS_TEST_ALLOC_REFUSE=renderer in longshot_env.txt, the title screen) - Linux and Windows, game-free: `python -I -B tests/run_all.py`, `test_renderer_new_handler` and `test_host_alloc_wait` above all, expecting them to pass, and the new test to fail on `main` with "mkwvk_init installs no new_handler" (by hand or CI: the run's table; not run on this PC by its owner's rule) ## Risks **What could break:** - Everything the renderer allocates with `new` goes through the handler when `malloc` refuses. A refusal that used to throw and be caught now waits up to 5 s and stops the game with the out-of-memory notice. One case: a background job's `std::bad_alloc` was caught by `run_guarded` (`gpu/vk/vk_jobs.cpp`), logged, and the game went on. - Not in a scope, on purpose (written in `vk_new.h`): the C++ library's own nothrow buffers (`std::stable_sort`, `std::inplace_merge`) and the renderer's other catch blocks around allocations (the caches' inserts, thread starts). At the limit they now wait with every other allocation, then stop with the notice. Before, the unwind to them often failed there anyway (`0xc00000ff` after the throw in #1217, #1182 and #981). - The 5 s are counted per thread, from the first refusal. A thread refused again within 250 ms of its last try goes on counting the same 5 s, so under heavy thrashing it can stop while memory is still coming back. - The handler waits on the refused thread, holding whatever locks it holds. The hang watches (10 s or more) don't fire in those 5 s. - With no size known, a refusal with over 1 GB of commit left is "not the limit": a fatal that says so, with no notice (as #341 does for a size gone wrong). - A nothrow `new` added later outside a `NewNothrow` scope waits and stops too, instead of getting its null. The new test's text check names any such line that writes `std::nothrow`. **Turning it off:** revert the commits. **Compatibility:** the vk ABI, `MKWVK_API_VERSION` 27 → 28: the host and the renderer must come from one build, as always. Saves, settings and caches don't change. ## Issues Fixes #1280 See #333, #341, #388 ## Checklist ### Everyone - [x] One topic. - [x] The title is a Conventional Commit (`type(scope): description`) of the status line's type. - [x] Why gives the reason plainly and links the issues that fit (the tracker searched). - [x] Measurements has a verdict, or one line saying why there is nothing to measure. - [x] Testing names what was tested, what wasn't, and what must still be tested, where and how. - [x] Rebased on current `main`. - [ ] `python -I -B tests/run_all.py` passes (any failure that also fails on `main` is named). Not run on this PC (the owner's rule): left to CI. - [x] No game files, dumps, build output or generated files. - [x] `third_party/` untouched (a new folder with a `PROVENANCE.md` instead). - [x] The license is OK: GPL-3.0-or-later, nothing incompatible and nothing decompiled. ### When it applies - [x] AI assistance recorded with `Assisted-by:` / `Co-Authored-By:` trailers. - [x] Switches documented (docs/development.md; the README for a menu row) and shipped at their recommended value. - [x] `MKWVK_API_VERSION` bumped (`gpu/vk/vk_api.h`'s `MkwVkHost` or `MkwVkRenderer` changed). - [ ] A game-free test added for the fix, failing on `main` and passing here. Added, not run here: CI. - [x] A check under `tests/` that reads changed source updated in this PR, not weakened. - [ ] Host code builds on both Windows (llvm-mingw) and Linux, with UTF-8 paths. Built on Linux only: Windows needs the Test Farm or CI. - [x] Docs updated. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
Fails on main: mkwvk_init installs no new_handler, so a refused operator new in
longshot_vk.dll throws std::bad_alloc that nothing catches (exception 0x20474343,
"An unexpected error"), and host/mkw_glue.c has no hos_alloc_gave_up for the
renderer to end through.

Assisted-by: Claude Code
Co-Authored-By: Claude Opus 5.5 <[email protected]>
fix(vk): at Windows' commit limit the renderer's C++ allocations wait for memory, then say out of memory (issue 1280)
Some checks failed
CI / Python source checks (ubuntu-24.04, part 1/2) (pull_request) Has been skipped
CI / Python source checks (ubuntu-24.04, part 2/2) (pull_request) Has been skipped
CI / SPIR-V fixtures (global narrow load/store, direct surface atomics, F2I immediate) (pull_request) Has been skipped
Third-party parts / The same as upstream (pull_request) Has been skipped
Website / Website on Cloudflare (pull_request) Has been skipped
CI / Conventional Commit title (pull_request) Successful in 7s
Guide screenshots / Guide images and local UI source review (pull_request) Failing after 10s
CI / Workflow lint (actionlint) (pull_request) Successful in 12s
Third-party parts / As their notes say (pull_request) Successful in 14s
Website / Website on Cloudflare (pull_request_target) Has been skipped
beanstalk/approval approved by HumanBean (reviewed)
beanstalk/windows 0/1 pass, 0 running, 0 queued
PR description / Description follows the template (pull_request_target) Failing after 5s
efd580acd2
A refused operator new in longshot_vk.dll threw std::bad_alloc that nothing
caught, and the game ended with exception 0x20474343 ("An unexpected error"):
no wait and no out-of-memory notice. mkwvk_init now installs a new_handler
(new_refused) that tries again every 50 ms for up to 5 s, then stops through the
host's out-of-memory line and notice: MkwVkHost out_of_memory (MKWVK_API_VERSION
27 -> 28), hos_alloc_gave_up split out of #341's hos_alloc_failed. Nothrow news
with a fallback of their own keep their null at once (NewNothrow, vk_new.h).
HOS_TEST_ALLOC_REFUSE=renderer asks for 1 PB at the 600th present to see it.

Assisted-by: Claude Code
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Author
Owner

Tested in game: RTX 3090, NVIDIA 620.70.06, Linux (CachyOS), headless to the title screen with HOS_TEST_ALLOC_REFUSE=renderer, twice (before and after the review fixes): the renderer's refused 1 PB allocation waited 5.0 s on the host thread (18.373 s to 23.375 s), then 'mem: the renderer's C++ allocations: still refused after 5 s at the commit limit', the out-of-memory line and 'FATAL: out of memory (RAM plus swap): the renderer's C++ allocations' (exit 3), no uncaught exception. Not run on Windows.

Tested in game: RTX 3090, NVIDIA 620.70.06, Linux (CachyOS), headless to the title screen with HOS_TEST_ALLOC_REFUSE=renderer, twice (before and after the review fixes): the renderer's refused 1 PB allocation waited 5.0 s on the host thread (18.373 s to 23.375 s), then 'mem: the renderer's C++ allocations: still refused after 5 s at the commit limit', the out-of-memory line and 'FATAL: out of memory (RAM plus swap): the renderer's C++ allocations' (exit 3), no uncaught exception. Not run on Windows.
Author
Owner

@Beanstalk windows, any GPU: with HOS_TEST_ALLOC_REFUSE=renderer in longshot_env.txt, start the game and wait at the title screen. Expected: about 10 s in, a 5 s pause, then the "Longshot: out of memory" notice, and the game stops once it is closed. longshot_log.txt should have "mem: the renderer's C++ allocations: still refused after 5 s at the commit limit" and "FATAL: out of memory (RAM plus the page file): the renderer's C++ allocations", and no "CRASH: exception 0x20474343". Please also run the game-free checks (python -I -B tests/run_all.py), test_renderer_new_handler and test_host_alloc_wait above all.

🤖 Generated with Claude Code

@Beanstalk windows, any GPU: with HOS_TEST_ALLOC_REFUSE=renderer in longshot_env.txt, start the game and wait at the title screen. Expected: about 10 s in, a 5 s pause, then the "Longshot: out of memory" notice, and the game stops once it is closed. longshot_log.txt should have "mem: the renderer's C++ allocations: still refused after 5 s at the commit limit" and "FATAL: out of memory (RAM plus the page file): the renderer's C++ allocations", and no "CRASH: exception 0x20474343". Please also run the game-free checks (python -I -B tests/run_all.py), test_renderer_new_handler and test_host_alloc_wait above all. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
Member

Beanstalk test farm

Commit efd580a · tier reviewed · approved by HumanBean · dashboard

What will be tested · AI plan (gpt-6.1-terra)

This Windows plan compares a normal title-screen start on the pull request and main for about 11 minutes per tester. It fails on a crash or a large title-screen image difference. The farm cannot reliably automate the requested out-of-memory notice and dismissal, expected fatal exit, or game-free Python checks, so those remain untested by this plan.

  • Where: windows (1-2 reports).
  • title-smoke: from the title screen, then take the picture title to compare with main; 1 run on each side.
  • Measured: crashes.
  • The PR fails if: it crashes; or a picture differs from main by more than 5%.
  • Time: about 11 min of game runs per tester (2 game starts), plus the two builds.

Done (started 01:02 UTC). Comment @Beanstalk to run it again.

Target Reports Crash Frame p99 (ms) vs main VRAM peak (MB) vs main Result
windows 0/1 — — — queued
<!-- beanstalk:sticky --> ### Beanstalk test farm Commit `efd580a` · tier **reviewed** · approved by HumanBean · [dashboard](https://beanstalk.magicbean.dev/prs/1291) **What will be tested** · AI plan (`gpt-6.1-terra`) This Windows plan compares a normal title-screen start on the pull request and main for about 11 minutes per tester. It fails on a crash or a large title-screen image difference. The farm cannot reliably automate the requested out-of-memory notice and dismissal, expected fatal exit, or game-free Python checks, so those remain untested by this plan. - **Where:** windows (1-2 reports). - **title-smoke:** from the title screen, then take the picture title to compare with main; 1 run on each side. - **Measured:** crashes. - **The PR fails if:** it crashes; or a picture differs from main by more than 5%. - **Time:** about 11 min of game runs per tester (2 game starts), plus the two builds. Done (started 01:02 UTC). Comment `@Beanstalk` to run it again. | Target | Reports | Crash | Frame p99 (ms) vs main | VRAM peak (MB) vs main | Result | | --- | --- | --- | --- | --- | --- | | windows | 0/1 | — | — | — | queued |
Collaborator

Possibly related, for context:

  • PR #1056 fix(crash): an uncaught C++ exception at Windows' commit limit shows as out of memory, not an unexpected error — Overlapping commit-limit C++ exception handling; changes diagnosis rather than allocation retry
Possibly related, for context: - PR #1056 fix(crash): an uncaught C++ exception at Windows' commit limit shows as out of memory, not an unexpected error — Overlapping commit-limit C++ exception handling; changes diagnosis rather than allocation retry
HumanBean changed title from WIP: fix(vk): at Windows' commit limit the renderer's C++ allocations wait for memory, then say out of memory to fix(vk): at Windows' commit limit the renderer's C++ allocations wait for memory, then say out of memory 2026-11-17 01:04:16 +00:00
HumanBean deleted branch push-lvooylormqzq 2026-11-17 01:04:23 +00:00
Sign in to join this conversation.
No reviewers
No milestone
No project
No assignees
3 participants
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
MagicBeanDev/Longshot!1291
No description provided.