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

Open
github-bot wants to merge 3 commits from github-bot/gh-2306 into main AGit
Owner

@⁠Tyrannys on GitHub · 2026-11-26 13:21 UTC · original
Tyrannys:rt-crash-log → main · +573 −6 · 8 files · 3 commits · open

Claimed in the coordination issue as: RT-CRASH-LOG (#1608)

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

**@⁠Tyrannys** on GitHub · 2026-11-26 13:21 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/2306) `Tyrannys:rt-crash-log` → `main` · +573 −6 · 8 files · 3 commits · open Claimed in the coordination issue as: RT-CRASH-LOG (https://git.gtahub.st/github/ubiquitarianism--leonida/issues/1608) 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)
A run that ended in an unhandled exception saved the pipeline
caches but said nothing about where the title faulted: the log
had the exception code and no call chain. print_fault_stacks
names the access and the address, walks the faulting thread's
own chain from the exception context (the filter runs on that
thread, so its stack is live), and snapshots the other threads
as LEONIDA_STACKS does. On the retail package this unwound a
faulting chain of six title frames out of the title's worker
pool and named the read that faulted, which no earlier log did.
thread_stacks_test covers it with a guarded null read captured
to a file.
On top of print_fault_stacks (#2276):
- the faulting context's registers (rax..r15, rip, eflags) and a host line
  (Windows build from RtlGetVersion, CPU brand from CPUID), as [rt] fault lines;
- for an exception other than an access violation, what its parameters say:
  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, or to LEONIDA_CRASH_LOG (0: no file),
  with Win32 calls only, so it outlives the console.

The text is built in src/crash_report.h, pure and portable, and checked by
crash_report_test on every platform. thread_stacks_test points the crash log
at a temporary file and checks its content.

Idea from Marvisak/VIctory (crates/victory-loader/src/crash.rs, GPL-3.0); no
code of it is used.

Changes made by Claude Code (AI-assisted).

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01JPqXc6svM4pbBagTsVEYA3
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 13:26:09 +00:00
Author
Owner

@⁠lixonik on GitHub · 2026-11-26 17:57 UTC · original · reviewed

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.

**@⁠lixonik** on GitHub · 2026-11-26 17:57 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/2306#pullrequestreview-6078690260) · **reviewed** 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.
Author
Owner

@⁠kawaii-shakal on GitHub · 2026-11-26 18:21 UTC · original · reviewed

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

**@⁠kawaii-shakal** on GitHub · 2026-11-26 18:21 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/2306#pullrequestreview-6078918746) · **reviewed** 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)_
This pull request can be merged automatically.
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 origin '+refs/pull/2306/head:github-bot/gh-2306'
git switch 'github-bot/gh-2306'

Merge

Merge the changes and update on Forgejo.
git switch 'main'
git merge --no-ff 'github-bot/gh-2306'
git switch 'github-bot/gh-2306'
git rebase 'main'
git switch 'main'
git merge --ff-only 'github-bot/gh-2306'
git switch 'github-bot/gh-2306'
git rebase 'main'
git switch 'main'
git merge --no-ff 'github-bot/gh-2306'
git switch 'main'
git merge --squash 'github-bot/gh-2306'
git switch 'main'
git merge --ff-only 'github-bot/gh-2306'
git switch 'main'
git merge 'github-bot/gh-2306'
git push origin 'main'
This discussion has been locked. Commenting is limited to contributors.
No description provided.