runtime: a fatal fault's report names its registers and host, and is kept in a crash log (RT-CRASH-LOG) #2306

Closed
Tyrannys wants to merge 3 commits from upstream-pr/2306 into main
Tyrannys commented 2026-11-26 13:21:45 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by Tyrannys on 2026-11-26T13:21:45Z.


Claimed in the coordination issue as: RT-CRASH-LOG (https://github.com/ubiquitarianism/leonida/issues/1608#issuecomment-7193120655)

Depends on: #2276

What and why

This is @kawaii-shakal's crash-log branch (commit 4be68530, their finding in #1608), built and tested on Windows. Their commits are kept as they are; this PR adds only a merge of current main.

kawaii-shakal's work (4be68530, on top of #2276's print_fault_stacks): a fatal fault's report from #2276 went to stderr only, so it was lost once the console closed, and it lacked the registers, the host and what a non-access-violation exception carries. With this:

  • the faulting context's registers (rax..r15, rip, eflags) and a host line (Windows build from RtlGetVersion, CPU brand from CPUID) are printed as [rt] fault lines;
  • an exception other than an access violation prints its parameters: a C++ throw's object, throw info and mangled type name (read under __try), an in-page error's status, or the raw parameters;
  • the whole report, after a dated header, is appended and flushed to %LOCALAPPDATA%\Leonida\crashes.log (Win32 calls only), or to the file LEONIDA_CRASH_LOG names; LEONIDA_CRASH_LOG=0 turns the file off;
  • the text is built in the portable src/crash_report.h and checked by crash_report_test; thread_stacks_test points the crash log at a temp file and checks its content; the variable is documented in runtime/README.md.

Windows fixes on top: none were needed. MSVC 19.52 compiles thread_stacks.cpp, thread_stacks_test.cpp, crash_report_test.cpp and gta6rt with no errors and no warnings in these files at /W4 /permissive-.

Tested

Windows 11 (10.0.26300), MSVC 19.52.37029, Ninja RelWithDebInfo, AMD Ryzen 7 9800X3D:

  • ctest -R "thread_stacks|crash_report": 2/2 pass. thread_stacks_test takes a real null read through print_fault_stacks and checks the temp crash log holds the dated header, the fault, the faulting thread's chain and the other threads.
  • A throwaway program (not committed) linking thread_stacks.cpp, with an unhandled-exception filter calling print_fault_stacks and returning EXCEPTION_CONTINUE_SEARCH, run with LOCALAPPDATA pointed at a temp folder:
    • an unhandled access violation (exit 0xc0000005) creates Leonida\crashes.log under it with the header, read of 0x14 at host:fault.exe+0x..., the registers, host: Windows 10.0.26300, CPU AMD Ryzen 7 9800X3D 8-Core Processor and the chain;
    • an unhandled C++ throw (exit 0xe06d7363) appends a second report with C++ exception: object ..., throw info ..., type .?AUMyError@@;
    • with LEONIDA_CRASH_LOG=0 the report still goes to stderr and no file is created.
  • tests/test_ctest_registration.py and scripts/check_no_game_data.py pass.

GPUs tested: n/a (CPU tests)

AI-assisted: yes (Claude Code). The original branch was also written with Claude Code, as kawaii-shakal noted in #1608.

Checklist

  • Based on current main and merges cleanly (a conflicting pull request is labeled needs rebase).
  • One topic; follow-up work goes in a new pull request.
  • No game data, keys or decryption (CONTRIBUTING.md), including in logs or reports quoted here.
  • A new translator rule is in the contract table of docs/design.md, with how it was confirmed. (n/a: no translator change)

🤖 Generated with Claude Code

<!-- greyfinch-sync:ubiquitarianism/leonida:issue:5510802830 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/2306). Originally posted by [Tyrannys](https://github.com/Tyrannys) on 2026-11-26T13:21:45Z. --- Claimed in the coordination issue as: RT-CRASH-LOG (https://github.com/ubiquitarianism/leonida/issues/1608#issuecomment-7193120655) Depends on: #2276 ### What and why This is @kawaii-shakal's `crash-log` branch (commit 4be68530, their finding in #1608), built and tested on Windows. Their commits are kept as they are; this PR adds only a merge of current `main`. **kawaii-shakal's work (4be68530, on top of #2276's `print_fault_stacks`):** a fatal fault's report from #2276 went to stderr only, so it was lost once the console closed, and it lacked the registers, the host and what a non-access-violation exception carries. With this: - the faulting context's registers (rax..r15, rip, eflags) and a host line (Windows build from `RtlGetVersion`, CPU brand from CPUID) are printed as `[rt] fault` lines; - an exception other than an access violation prints its parameters: a C++ throw's object, throw info and mangled type name (read under `__try`), an in-page error's status, or the raw parameters; - the whole report, after a dated header, is appended and flushed to `%LOCALAPPDATA%\Leonida\crashes.log` (Win32 calls only), or to the file `LEONIDA_CRASH_LOG` names; `LEONIDA_CRASH_LOG=0` turns the file off; - the text is built in the portable `src/crash_report.h` and checked by `crash_report_test`; `thread_stacks_test` points the crash log at a temp file and checks its content; the variable is documented in `runtime/README.md`. **Windows fixes on top:** none were needed. MSVC 19.52 compiles `thread_stacks.cpp`, `thread_stacks_test.cpp`, `crash_report_test.cpp` and `gta6rt` with no errors and no warnings in these files at `/W4 /permissive-`. ### Tested Windows 11 (10.0.26300), MSVC 19.52.37029, Ninja RelWithDebInfo, AMD Ryzen 7 9800X3D: - `ctest -R "thread_stacks|crash_report"`: 2/2 pass. `thread_stacks_test` takes a real null read through `print_fault_stacks` and checks the temp crash log holds the dated header, the fault, the faulting thread's chain and the other threads. - A throwaway program (not committed) linking `thread_stacks.cpp`, with an unhandled-exception filter calling `print_fault_stacks` and returning `EXCEPTION_CONTINUE_SEARCH`, run with `LOCALAPPDATA` pointed at a temp folder: - an unhandled access violation (exit 0xc0000005) creates `Leonida\crashes.log` under it with the header, `read of 0x14 at host:fault.exe+0x...`, the registers, `host: Windows 10.0.26300, CPU AMD Ryzen 7 9800X3D 8-Core Processor` and the chain; - an unhandled C++ throw (exit 0xe06d7363) appends a second report with `C++ exception: object ..., throw info ..., type .?AUMyError@@`; - with `LEONIDA_CRASH_LOG=0` the report still goes to stderr and no file is created. - `tests/test_ctest_registration.py` and `scripts/check_no_game_data.py` pass. GPUs tested: n/a (CPU tests) AI-assisted: yes (Claude Code). The original branch was also written with Claude Code, as kawaii-shakal noted in #1608. ### Checklist - [x] Based on current `main` and merges cleanly (a conflicting pull request is labeled `needs rebase`). - [x] One topic; follow-up work goes in a new pull request. - [x] No game data, keys or decryption (CONTRIBUTING.md), including in logs or reports quoted here. - [ ] A new translator rule is in the contract table of `docs/design.md`, with how it was confirmed. (n/a: no translator change) 🤖 Generated with [Claude Code](https://claude.com/claude-code)
lixonik commented 2026-11-26 17:57:41 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by lixonik on 2026-11-26T17:57:41Z.

Review: COMMENTED


Windows 11/MSVC: crash_report and thread_stacks both passed using the repo's fixtures. A title boot and actual title crash were outside this run.

AI-assisted.

<!-- greyfinch-sync:ubiquitarianism/leonida:review:6078690260 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/2306#pullrequestreview-6078690260). Originally posted by [lixonik](https://github.com/lixonik) on 2026-11-26T17:57:41Z. **Review:** COMMENTED --- Windows 11/MSVC: `crash_report` and `thread_stacks` both passed using the repo's fixtures. A title boot and actual title crash were outside this run. AI-assisted.
kawaii-shakal commented 2026-11-26 18:21:17 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by kawaii-shakal on 2026-11-26T18:21:17Z.

Review: COMMENTED


Reviewed by Claude Code (AI-assisted) on my behalf. Comment, not an approval: the code is my commit 4be68530,
unchanged. The diff against my crash-log branch is only the merge of main, so an approval from me would be
approving my own code.

Thanks for taking it over and for the Windows run, which was the part I could not do. MSVC 19.52 at
/W4 /permissive-, thread_stacks_test and crash_report_test passing, and the manual AV and C++-throw reports
checked in the log were exactly what was missing. lixonik's run confirms the tests too.

Two known limits:

  1. The filter allocates (std::string, the module lookup, the thread snapshot), as #2276 already did. A fault inside
    the process heap, or while the loader's lookup mutex is held, can hang there instead of ending the process. A
    nested fault inside call_once would block too. Not worse than #2276, but worth knowing when a crash "hangs".
  2. read_thrown_type follows the throw info without checking the magic in parameter 0 (0x19930520..0x19930522). A
    foreign 0xE06D7363 with garbage parameters is caught by __try and gives no type, so it fails safe, but checking
    the magic first would skip the reads.

Neither blocks. A maintainer or another reviewer should give the approval.


Generated by Claude Code

<!-- greyfinch-sync:ubiquitarianism/leonida:review:6078918746 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/2306#pullrequestreview-6078918746). Originally posted by [kawaii-shakal](https://github.com/kawaii-shakal) on 2026-11-26T18:21:17Z. **Review:** COMMENTED --- Reviewed by Claude Code (AI-assisted) on my behalf. Comment, not an approval: the code is my commit 4be68530, unchanged. The diff against my `crash-log` branch is only the merge of main, so an approval from me would be approving my own code. Thanks for taking it over and for the Windows run, which was the part I could not do. MSVC 19.52 at `/W4 /permissive-`, `thread_stacks_test` and `crash_report_test` passing, and the manual AV and C++-throw reports checked in the log were exactly what was missing. lixonik's run confirms the tests too. Two known limits: 1. The filter allocates (`std::string`, the module lookup, the thread snapshot), as #2276 already did. A fault inside the process heap, or while the loader's lookup mutex is held, can hang there instead of ending the process. A nested fault inside `call_once` would block too. Not worse than #2276, but worth knowing when a crash "hangs". 2. `read_thrown_type` follows the throw info without checking the magic in parameter 0 (0x19930520..0x19930522). A foreign 0xE06D7363 with garbage parameters is caught by `__try` and gives no type, so it fails safe, but checking the magic first would skip the reads. Neither blocks. A maintainer or another reviewer should give the approval. --- _Generated by [Claude Code](https://claude.ai/code)_
zmasi commented 2026-11-28 12:38:48 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by zmasi on 2026-11-28T12:38:48Z.


Verified on Windows 11 (10.0.26200.9974) with MSVC 19.44.35228 (x64, /std:c++20 /EHsc /W4 /permissive- /utf-8 /O2) against main d48a957bb + c2dc711333 (claim #2570#issuecomment-7239309422):

  • Line-by-line diff audit: Clean (runtime/CMakeLists.txt, runtime/README.md, runtime/src/crash_report.h, runtime/src/main.cpp, runtime/src/thread_stacks.cpp, runtime/src/thread_stacks.h, runtime/test/crash_report_test.cpp, runtime/test/thread_stacks_test.cpp); adds portable register/exception/host formatting, RtlGetVersion + __cpuid host diagnostics, SEH-guarded MSVC ThrowInfo type-name inspection, live faulting-thread stack unwinding, and flushed LEONIDA_CRASH_LOG / %LOCALAPPDATA%\Leonida\crashes.log persistence. check_no_game_data.py and test_docs_encoding.py clean.
  • Red (d48a957bb + PR test): Fails to build (rc=2, error C2039: 'print_fault_stacks': is not a member of 'rt').
  • Green (d48a957bb + c2dc711333 merge): Auto-merges cleanly (rc=0), compiles thread_stacks_test.exe and crash_report_test.exe with 0 warnings under /W4 /permissive-, passes thread_stacks_test.exe (23 checks, 0 failures, rc=0) and crash_report_test.exe (crash_report_test: all checks passed, rc=0), and compiles runtime/src/main.cpp cleanly (0 new warnings).
  • Non-blocking notes: Supersedes/extends #2276 and overlaps #2555 on main.cpp fatal-exception reporting. Two minor nits in thread_stacks.cpp: line 401 could call crash_report::access_kind(...) so unexpected ExceptionInformation[0] values format as "access" rather than "execute", and read_thrown_type (lines 309-315, safely inside __try) reads 32-bit x64 ThrowInfo RVAs as signed int32_t rather than uint32_t (which would sign-extend RVAs >= 0x80000000 in >2 GiB images).

AI-assisted.

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7239370477 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/2306#issuecomment-7239370477). Originally posted by [zmasi](https://github.com/zmasi) on 2026-11-28T12:38:48Z. --- Verified on Windows 11 (`10.0.26200.9974`) with MSVC `19.44.35228` (`x64`, `/std:c++20 /EHsc /W4 /permissive- /utf-8 /O2`) against `main` `d48a957bb` + `c2dc711333` (claim `#2570#issuecomment-7239309422`): - **Line-by-line diff audit**: Clean (`runtime/CMakeLists.txt`, `runtime/README.md`, `runtime/src/crash_report.h`, `runtime/src/main.cpp`, `runtime/src/thread_stacks.cpp`, `runtime/src/thread_stacks.h`, `runtime/test/crash_report_test.cpp`, `runtime/test/thread_stacks_test.cpp`); adds portable register/exception/host formatting, `RtlGetVersion` + `__cpuid` host diagnostics, SEH-guarded MSVC `ThrowInfo` type-name inspection, live faulting-thread stack unwinding, and flushed `LEONIDA_CRASH_LOG` / `%LOCALAPPDATA%\Leonida\crashes.log` persistence. `check_no_game_data.py` and `test_docs_encoding.py` clean. - **Red (`d48a957bb` + PR test)**: Fails to build (`rc=2`, `error C2039: 'print_fault_stacks': is not a member of 'rt'`). - **Green (`d48a957bb` + `c2dc711333` merge)**: Auto-merges cleanly (`rc=0`), compiles `thread_stacks_test.exe` and `crash_report_test.exe` with `0` warnings under `/W4 /permissive-`, passes `thread_stacks_test.exe` (`23 checks, 0 failures`, `rc=0`) and `crash_report_test.exe` (`crash_report_test: all checks passed`, `rc=0`), and compiles `runtime/src/main.cpp` cleanly (`0` new warnings). - **Non-blocking notes**: Supersedes/extends `#2276` and overlaps `#2555` on `main.cpp` fatal-exception reporting. Two minor nits in `thread_stacks.cpp`: line 401 could call `crash_report::access_kind(...)` so unexpected `ExceptionInformation[0]` values format as `"access"` rather than `"execute"`, and `read_thrown_type` (`lines 309-315`, safely inside `__try`) reads 32-bit x64 `ThrowInfo` RVAs as signed `int32_t` rather than `uint32_t` (which would sign-extend RVAs `>= 0x80000000` in >2 GiB images). AI-assisted.
TheGeogeo commented 2026-11-28 22:16:39 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by TheGeogeo on 2026-11-28T22:16:39Z.


Duplicate check (diff reading only, no build): not a duplicate of #2276. It is stacked on it (it contains #2276's commit) and adds the registers, the host and the crash log file (crash_report.h, thread_stacks.cpp). It needs a rebase (needs rebase).

Heads-up: this PR and #2276 both conflict in runtime/src/main.cpp with #2555 (git merge-tree). #2555 also prints a fatal exception's registers and stack, so the two register reports overlap. Worth choosing one before merging.

AI-assisted (Claude Code).

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7246621743 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/2306#issuecomment-7246621743). Originally posted by [TheGeogeo](https://github.com/TheGeogeo) on 2026-11-28T22:16:39Z. --- Duplicate check (diff reading only, no build): not a duplicate of #2276. It is stacked on it (it contains #2276's commit) and adds the registers, the host and the crash log file (`crash_report.h`, `thread_stacks.cpp`). It needs a rebase (`needs rebase`). Heads-up: this PR and #2276 both conflict in `runtime/src/main.cpp` with #2555 (`git merge-tree`). #2555 also prints a fatal exception's registers and stack, so the two register reports overlap. Worth choosing one before merging. AI-assisted (Claude Code).
KelboLive commented 2026-11-30 18:11:11 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by KelboLive on 2026-11-30T18:11:11Z.


Independent check on Windows (not the author), at c2dc71133.

  • Built and ran crash_report_test: all checks passed (LEONIDA_CRASH_LOG=0 writes no file, any other value is a path, only a lone 0 turns it off).
  • Built and ran thread_stacks_test: 23 checks, 0 failures — the crash report starts with its dated header and holds the fault, the faulting thread's chain and the other threads.

Environment: Ryzen 9 7950X3D, Windows 11 Pro 10.0.26200.9711.

AI-assisted: yes (opencode).

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7287474861 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/2306#issuecomment-7287474861). Originally posted by [KelboLive](https://github.com/KelboLive) on 2026-11-30T18:11:11Z. --- Independent check on Windows (not the author), at `c2dc71133`. - Built and ran `crash_report_test`: **all checks passed** (`LEONIDA_CRASH_LOG=0` writes no file, any other value is a path, only a lone `0` turns it off). - Built and ran `thread_stacks_test`: **23 checks, 0 failures** — the crash report starts with its dated header and holds the fault, the faulting thread's chain and the other threads. Environment: Ryzen 9 7950X3D, Windows 11 Pro 10.0.26200.9711. AI-assisted: yes (opencode).
aslan2142 commented 2026-12-01 16:43:39 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by aslan2142 on 2026-12-01T16:43:39Z.


Closing this PR because the legacy C++ Vulkan runtime (and legacy Python shader compiler) is now considered deprecated in favor of the new Rust Vulkan runtime (in progress) and the Rust DX12 runtime (d3d12/) available now. Thank you for the contribution! If you believe this PR was closed by mistake (for example, if it still applies to active tools, d3d12/, or general docs), please feel free to reopen it.

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7318113178 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/2306#issuecomment-7318113178). Originally posted by [aslan2142](https://github.com/aslan2142) on 2026-12-01T16:43:39Z. --- Closing this PR because the legacy C++ Vulkan runtime (and legacy Python shader compiler) is now considered deprecated in favor of the new Rust Vulkan runtime (in progress) and the Rust DX12 runtime (`d3d12/`) available now. Thank you for the contribution! If you believe this PR was closed by mistake (for example, if it still applies to active tools, `d3d12/`, or general docs), please feel free to reopen it.

Pull request closed

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
ProjectLeonida/mandy!2306
No description provided.