fix(crash): an uncaught C++ exception at Windows' commit limit shows as out of memory, not an unexpected error #1056

Open
d4nkn3ss wants to merge 3 commits from d4nkn3ss/Longshot:fix/crash-window-commit-limit into main
Contributor

Type: fix · Risk: low · Tested on: Windows 11, RTX 3080 · Needs: Linux, any GPU

Why

Players whose game ran out of memory are told "An unexpected error" by the crash window, not that their PC ran out of memory and what to do about it. Six recent reports end with exception: 0x20474343: #1029, #1030, #991, #981, #964 and #894. That code is llvm-mingw's for a C++ exception nothing caught, and here it was thrown in the renderer. Five of their logs had reached Windows' commit limit (RAM plus the page file) just before:

  • mem: commit of 0xc0000 bytes at the commit limit made after 50 ms (7 so far);
  • vk: commit limit near: 47 MB of commit left;
  • 16 such lines on #1029's 8 GB PC.

So the likeliest throw is a failed allocation. The crash window's log reader counts mem: Windows is out of memory ... and a failed commit (error 1455), but neither of these lines. The diagnosis is on #1029. Row 5.6 of the worklist (memory over play time) is where this sits.

This branch builds on #1012, whose commit (test_crash_dialog runs on Windows) it carries first: without it the check can't run on Windows at all. Merge #1012 first; this PR's own change is the last two commits.

How to reproduce

Seen on: Windows 11, RTX 3080 (NVIDIA 621.14), with the crash window shown from files (as a start shows a crash record)
Settings and switches: none
Steps: a crash record with reason: unhandled exception, exception: 0x20474343, and its run's longshot_log.txt (the record's run_id in it) holding the two commit-limit lines above; longshot --crash-show crash-<UTC>.txt <game folder> <log> <options>
Expected: "What went wrong: Your PC ran out of memory. ..."
Actual: "What went wrong: An unexpected error."

What changed

The crash window's log facts note when the process had reached the commit limit. With this exception code that makes the cause memory, so the window shows the out-of-memory advice. Another exception at the limit, or this one further from it, stays "An unexpected error".

  • host: host/hos_crash_dialog.h:
    • HosCrashLog.commit_limit: set by a commit host/mkw_glue.c made "at the commit limit", or by the renderer's commit reserve with 512 MB or less left (vk: commit limit near: N MB of commit left);
    • hos_crash_cause: r->code == 0x20474343 with commit_limit returns HOS_CAUSE_MEMORY.
  • tests: tests/test_crash_dialog.py: verdict cases for that exception with a commit made at the limit (memory), 48 and 512 MB left (memory), 1719 MB left (unknown), no commit lines (unknown), and an access violation at the limit (unknown). They fail on main.

Measurements

Verdict: fixed: the same crash record and log show "Your PC ran out of memory" with this PR and "An unexpected error" on main.

Hardware: Windows 11 Pro 26300, RTX 3080 10 GB (NVIDIA 621.14), i9-12900K, 64 GB
Scene: the crash window only, from a scratch game folder: one record and one log as above
Method: each build's longshot.exe --crash-show crash-20261115T120000Z.txt <folder> <log> <options>, its window captured
Baseline: main's side is main @ 1764fed2's build; this PR was on 1764fed2 when built and is rebased onto bbe421f5 since. git diff 1764fed2 bbe421f5 -- host/hos_crash_dialog.h host/hos_crash_dialog.c is empty.
How to reproduce: the steps above

the window's "What went wrong" Before: main @ 1764fed2 After: this PR @ e3e97ec3
0x20474343, the log at the commit limit An unexpected error. Your PC ran out of memory. Close other programs and try again; Longshot needs 16 GB of RAM, and on Windows a page file Windows manages.
crash-20261115T120000Z.txt: reason: unhandled exception / exception: 0x20474343 / module_offset: KERNELBASE.dll+0xc408a
longshot_log.txt:
[hos host] run_id: 0123456789abcdef0123456789abcdef
[hos BaseProcExecutor1] map: HyruleField_Adult (adult)
[hos Resource Memory] mem: commit of 0xc0000 bytes at the commit limit made after 50 ms (7 so far)
[hos Presentation Thread] vk: commit limit near: 47 MB of commit left (reserve 2560 MB); the textures' budget down to 0 MB of their 1500 MB (RX_VK_COMMIT_RESERVE_MB)

Seen on the way, not changed here: at this screen's scale both builds cut the third button's label to "pen the log fold" ("Open the log folder").

Flags and settings

None

Testing

Tested:

  • The crash window in the game's own exe, both builds, as above.
  • python -I -B tests/test_crash_dialog.py: the new cases fail on #1012's branch without the fix (at the first one, a commit made at the limit) and pass here.
  • python -I -B tests/run_all.py from PowerShell with llvm-mingw from the Longshot Builder: 599 passed, 18 failed, 42 skipped. The 18 are main's own: test_auto_handheld, test_bug_report_defaults, test_crt_options, test_fsr_uniform_ownership, test_guest_imported, test_import_reach, test_linux_preflight, test_make_game_cache, test_missing_nup, test_pads_after_menu, test_parallel_init_order, test_pending_guest_import, test_release, test_replay_write_order, test_run_all_changed, test_tested_configurations, test_vk_occlusion_queries and test_walk_key. Main also fails test_crash_dialog, which #1012 and this PR pass.

Not tested: Linux, neither the build nor the window. The facts and the cause are plain C, and the exception code is llvm-mingw's (Windows): on Linux this rule never applies. A real crash at the commit limit: I can't make this PC's 64 GB run out.

Must be tested:

  • Linux, any GPU: build the host, then python -I -B tests/run_all.py test_crash_dialog, expecting it to pass (by hand: the check's line)

Risks

What could break: a crash at the limit whose exception wasn't an allocation would now show the memory advice. Only this code at the limit is affected. An access violation there, or any other code, stays unknown.

Turning it off: revert the commit.

Compatibility: Nothing changes for players beyond these crashes' window text, and the Report's verdict with it.

Issues

See #1029, #1030, #991, #981, #964, #894

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).
  • 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.
  • A game-free test added for the fix, failing on main and passing here.
  • A check under tests/ that reads changed source updated in this PR, not weakened.

🤖 Generated with Claude Code

**Type:** fix · **Risk:** low · **Tested on:** Windows 11, RTX 3080 · **Needs:** Linux, any GPU ## Why Players whose game ran out of memory are told "An unexpected error" by the crash window, not that their PC ran out of memory and what to do about it. Six recent reports end with `exception: 0x20474343`: #1029, #1030, #991, #981, #964 and #894. That code is llvm-mingw's for a C++ exception nothing caught, and here it was thrown in the renderer. Five of their logs had reached Windows' commit limit (RAM plus the page file) just before: - `mem: commit of 0xc0000 bytes at the commit limit made after 50 ms (7 so far)`; - `vk: commit limit near: 47 MB of commit left`; - 16 such lines on #1029's 8 GB PC. So the likeliest throw is a failed allocation. The crash window's log reader counts `mem: Windows is out of memory ...` and a failed commit (`error 1455`), but neither of these lines. The diagnosis is on #1029. Row 5.6 of the worklist (memory over play time) is where this sits. **This branch builds on #1012**, whose commit (`test_crash_dialog` runs on Windows) it carries first: without it the check can't run on Windows at all. Merge #1012 first; this PR's own change is the last two commits. ## How to reproduce **Seen on:** Windows 11, RTX 3080 (NVIDIA 621.14), with the crash window shown from files (as a start shows a crash record) **Settings and switches:** none **Steps:** a crash record with `reason: unhandled exception`, `exception: 0x20474343`, and its run's `longshot_log.txt` (the record's `run_id` in it) holding the two commit-limit lines above; `longshot --crash-show crash-<UTC>.txt <game folder> <log> <options>` **Expected:** "What went wrong: Your PC ran out of memory. ..." **Actual:** "What went wrong: An unexpected error." ## What changed The crash window's log facts note when the process had reached the commit limit. With this exception code that makes the cause memory, so the window shows the out-of-memory advice. Another exception at the limit, or this one further from it, stays "An unexpected error". - host: `host/hos_crash_dialog.h`: - `HosCrashLog.commit_limit`: set by a commit `host/mkw_glue.c` made "at the commit limit", or by the renderer's commit reserve with 512 MB or less left (`vk: commit limit near: N MB of commit left`); - `hos_crash_cause`: `r->code == 0x20474343` with `commit_limit` returns `HOS_CAUSE_MEMORY`. - tests: `tests/test_crash_dialog.py`: verdict cases for that exception with a commit made at the limit (memory), 48 and 512 MB left (memory), 1719 MB left (unknown), no commit lines (unknown), and an access violation at the limit (unknown). They fail on main. ## Measurements **Verdict:** fixed: the same crash record and log show "Your PC ran out of memory" with this PR and "An unexpected error" on main. Hardware: Windows 11 Pro 26300, RTX 3080 10 GB (NVIDIA 621.14), i9-12900K, 64 GB Scene: the crash window only, from a scratch game folder: one record and one log as above Method: each build's `longshot.exe --crash-show crash-20261115T120000Z.txt <folder> <log> <options>`, its window captured Baseline: main's side is main @ 1764fed2's build; this PR was on 1764fed2 when built and is rebased onto bbe421f5 since. `git diff 1764fed2 bbe421f5 -- host/hos_crash_dialog.h host/hos_crash_dialog.c` is empty. How to reproduce: the steps above | the window's "What went wrong" | Before: main @ 1764fed2 | After: this PR @ e3e97ec3 | |---|---|---| | `0x20474343`, the log at the commit limit | An unexpected error. | Your PC ran out of memory. Close other programs and try again; Longshot needs 16 GB of RAM, and on Windows a page file Windows manages. | ``` crash-20261115T120000Z.txt: reason: unhandled exception / exception: 0x20474343 / module_offset: KERNELBASE.dll+0xc408a longshot_log.txt: [hos host] run_id: 0123456789abcdef0123456789abcdef [hos BaseProcExecutor1] map: HyruleField_Adult (adult) [hos Resource Memory] mem: commit of 0xc0000 bytes at the commit limit made after 50 ms (7 so far) [hos Presentation Thread] vk: commit limit near: 47 MB of commit left (reserve 2560 MB); the textures' budget down to 0 MB of their 1500 MB (RX_VK_COMMIT_RESERVE_MB) ``` Seen on the way, not changed here: at this screen's scale both builds cut the third button's label to "pen the log fold" ("Open the log folder"). ### Flags and settings None ## Testing **Tested:** - The crash window in the game's own exe, both builds, as above. - `python -I -B tests/test_crash_dialog.py`: the new cases fail on #1012's branch without the fix (at the first one, a commit made at the limit) and pass here. - `python -I -B tests/run_all.py` from PowerShell with llvm-mingw from the Longshot Builder: 599 passed, 18 failed, 42 skipped. The 18 are main's own: `test_auto_handheld`, `test_bug_report_defaults`, `test_crt_options`, `test_fsr_uniform_ownership`, `test_guest_imported`, `test_import_reach`, `test_linux_preflight`, `test_make_game_cache`, `test_missing_nup`, `test_pads_after_menu`, `test_parallel_init_order`, `test_pending_guest_import`, `test_release`, `test_replay_write_order`, `test_run_all_changed`, `test_tested_configurations`, `test_vk_occlusion_queries` and `test_walk_key`. Main also fails `test_crash_dialog`, which #1012 and this PR pass. **Not tested:** Linux, neither the build nor the window. The facts and the cause are plain C, and the exception code is llvm-mingw's (Windows): on Linux this rule never applies. A real crash at the commit limit: I can't make this PC's 64 GB run out. **Must be tested:** - Linux, any GPU: build the host, then `python -I -B tests/run_all.py test_crash_dialog`, expecting it to pass (by hand: the check's line) ## Risks **What could break:** a crash at the limit whose exception wasn't an allocation would now show the memory advice. Only this code at the limit is affected. An access violation there, or any other code, stays unknown. **Turning it off:** revert the commit. **Compatibility:** Nothing changes for players beyond these crashes' window text, and the Report's verdict with it. ## Issues See #1029, #1030, #991, #981, #964, #894 ## 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`. - [x] `python -I -B tests/run_all.py` passes (any failure that also fails on `main` is named). - [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] A game-free test added for the fix, failing on `main` and passing here. - [x] A check under `tests/` that reads changed source updated in this PR, not weakened. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
Two things stopped test_crash_dialog on Windows. Its quoting case passed
"ゲーム Zélda 🎮" on the fixture's command line, which Windows hands a narrow
argv over in the ANSI code page: the fixture printed é as byte 0xe9 and
reading its output as UTF-8 failed. The case now sends the argument as hex,
which the fixture decodes, so the bytes are exact on every OS. Then its
record() wrote crash records in text mode, CR LF on Windows, which the
dialog's reader didn't take for records, so every verdict came back quiet.
The game writes them with WriteFile, LF. They are written with LF now. The
log files stay as they were: the reader takes CR LF logs.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Six crash reports (issue 1029, 1030, 991, 981, 964, 894) end with
exception 0x20474343, llvm-mingw's code for a C++ exception nothing caught,
thrown in the renderer, and five of their logs had reached Windows' commit
limit first ("mem: commit ... at the commit limit made after ...", "vk:
commit limit near: 47 MB of commit left"): an allocation that failed. The
crash window called it "An unexpected error", so these players never saw
the out-of-memory advice. New verdict cases: with that exception and a log at
the limit (a commit made at it, or 512 MB of commit or less left) the cause
is memory; further from the limit, or another exception there, it stays
unknown. Fails on main.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
fix(crash): an uncaught C++ exception at Windows' commit limit shows as out of memory, not an unexpected error
Some checks are pending
CI / Conventional Commit title (pull_request) Blocked by required conditions
CI / Python source checks (ubuntu-24.04, part 1/2) (pull_request) Blocked by required conditions
CI / Python source checks (ubuntu-24.04, part 2/2) (pull_request) Blocked by required conditions
CI / SPIR-V fixtures (global narrow load/store, direct surface atomics, F2I immediate) (pull_request) Blocked by required conditions
CI / Workflow lint (actionlint) (pull_request) Blocked by required conditions
Guide screenshots / Guide images and local UI source review (pull_request) Blocked by required conditions
Third-party parts / As their notes say (pull_request) Blocked by required conditions
Third-party parts / The same as upstream (pull_request) Blocked by required conditions
PR description / Description follows the template (pull_request_target) Successful in 3s
Website / Website on Cloudflare (pull_request_target) Has been skipped
e3e97ec3a5
Six crash reports (issue 1029, 1030, 991, 981, 964, 894) ended with
exception 0x20474343, a C++ exception nothing caught, thrown in the
renderer, and five of their logs had reached Windows' commit limit first:
an allocation that failed. The crash window said "An unexpected error", so
those players never saw the advice that fits (close programs, a larger page
file).

The log's facts note the commit limit reached (commit_limit): a commit
host/mkw_glue.c made "at the commit limit", or the renderer's commit
reserve with 512 MB or less left ("vk: commit limit near: N MB of commit
left"). With that exception code the cause is memory. Another exception at
the limit, or this one further from it, stays unknown.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Author
Contributor

Tested in game: Windows 11, RTX 3080 (NVIDIA 621.14): the crash window of this build's longshot.exe and main's, shown with --crash-show from the same crash record (exception 0x20474343) and log (at the commit limit): main says An unexpected error, this build Your PC ran out of memory

Tested in game: Windows 11, RTX 3080 (NVIDIA 621.14): the crash window of this build's longshot.exe and main's, shown with --crash-show from the same crash record (exception 0x20474343) and log (at the commit limit): main says An unexpected error, this build Your PC ran out of memory
d4nkn3ss changed title from WIP: fix(crash): an uncaught C++ exception at Windows' commit limit shows as out of memory, not an unexpected error to fix(crash): an uncaught C++ exception at Windows' commit limit shows as out of memory, not an unexpected error 2026-11-16 05:21:36 +00:00
Member

Code-only review of e3e97ec3a5; informational findings, with final approval left to another reviewer.

P2 — Historical pressure is treated as the cause of a later crash. In host/hos_crash_dialog.h:197–199, commit_limit is only set, never cleared. read_log() in host/hos_crash_dialog.c feeds it the whole run, and line 312 turns any later 0x20474343 exception into the definite “Your PC ran out of memory” diagnosis. For example, the existing fixture's log(near % 48, near % 1719) still returns MEMORY, although the newer sample is above this PR's threshold. The other accepted line is emitted by host/mkw_glue.c:34 after VirtualAlloc succeeds on retry, so a recovered allocation also permanently sets this flag. The PR itself identifies this exception as generic C++, rather than identifying its thrown type.

Please keep historical pressure separate from a confirmed allocation failure: use qualified “may have run out of memory” advice for this heuristic, or require sufficiently recent allocation-failure evidence before selecting the definite memory cause. If retaining a current-pressure flag, update it when newer headroom evidence arrives. Add a regression for low headroom followed by recovery and a later generic exception; the new tests only cover each headroom value independently. This is a source-derived diagnostic false-positive case, not a reproduced player crash.

The author reports Windows 11 / RTX 3080 crash-window A/B evidence and the new fixture passing, with 18 named existing suite failures. The requested Linux host build and crash-dialog check remain outstanding; I ran no tests, builds, or game. Those checks would validate portability, not establish the actual exception type in the six reports.

Merge coordination: 1012 is still open and supplies this branch's Windows fixture changes; merge it first as requested in the description. 983 and 141 also change crash-cause handling for Linux OOM reporting; preserve both rules when integrating. Reviewed the full diff, log producers/consumer, diagnostic text, relevant fixture paths, and existing feedback. No source changes or remote review actions made.

Code-only review of e3e97ec3a56f200d0d992e2b8b7e057d9bc4024a; informational findings, with final approval left to another reviewer. **P2 — Historical pressure is treated as the cause of a later crash.** In `host/hos_crash_dialog.h:197–199`, `commit_limit` is only set, never cleared. `read_log()` in `host/hos_crash_dialog.c` feeds it the whole run, and line 312 turns any later `0x20474343` exception into the definite “Your PC ran out of memory” diagnosis. For example, the existing fixture's `log(near % 48, near % 1719)` still returns `MEMORY`, although the newer sample is above this PR's threshold. The other accepted line is emitted by `host/mkw_glue.c:34` **after VirtualAlloc succeeds on retry**, so a recovered allocation also permanently sets this flag. The PR itself identifies this exception as generic C++, rather than identifying its thrown type. Please keep historical pressure separate from a confirmed allocation failure: use qualified “may have run out of memory” advice for this heuristic, or require sufficiently recent allocation-failure evidence before selecting the definite memory cause. If retaining a current-pressure flag, update it when newer headroom evidence arrives. Add a regression for low headroom followed by recovery and a later generic exception; the new tests only cover each headroom value independently. This is a source-derived diagnostic false-positive case, not a reproduced player crash. The author reports Windows 11 / RTX 3080 crash-window A/B evidence and the new fixture passing, with 18 named existing suite failures. The requested Linux host build and crash-dialog check remain outstanding; I ran no tests, builds, or game. Those checks would validate portability, not establish the actual exception type in the six reports. Merge coordination: [1012](https://git.magicbean.dev/MagicBeanDev/Longshot/pulls/1012) is still open and supplies this branch's Windows fixture changes; merge it first as requested in the description. [983](https://git.magicbean.dev/MagicBeanDev/Longshot/pulls/983) and [141](https://git.magicbean.dev/MagicBeanDev/Longshot/pulls/141) also change crash-cause handling for Linux OOM reporting; preserve both rules when integrating. Reviewed the full diff, log producers/consumer, diagnostic text, relevant fixture paths, and existing feedback. No source changes or remote review actions made.
Some checks are pending
CI / Conventional Commit title (pull_request) Blocked by required conditions
CI / Python source checks (ubuntu-24.04, part 1/2) (pull_request) Blocked by required conditions
CI / Python source checks (ubuntu-24.04, part 2/2) (pull_request) Blocked by required conditions
CI / SPIR-V fixtures (global narrow load/store, direct surface atomics, F2I immediate) (pull_request) Blocked by required conditions
CI / Workflow lint (actionlint) (pull_request) Blocked by required conditions
Guide screenshots / Guide images and local UI source review (pull_request) Blocked by required conditions
Third-party parts / As their notes say (pull_request) Blocked by required conditions
Third-party parts / The same as upstream (pull_request) Blocked by required conditions
PR description / Description follows the template (pull_request_target) Successful in 3s
Website / Website on Cloudflare (pull_request_target) Has been skipped
This pull request doesn't have enough approvals yet. 0 of 1 approvals granted.
Some workflows are waiting to be reviewed.
This branch is out-of-date with the base branch
You are not authorized to merge this pull request.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u 'fix/crash-window-commit-limit:d4nkn3ss-fix/crash-window-commit-limit'
git switch 'd4nkn3ss-fix/crash-window-commit-limit'
Sign in to join this conversation.
No reviewers
No milestone
No project
No assignees
2 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!1056
No description provided.