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

Open
opened 2026-11-26 21:20:46 +01:00 by 4ld0 · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/ubiquitarianism/leonida/pull/2306
Author: @Tyrannys
Created: 11/26/2026
Status: 🔄 Open

Base: main ← Head: rt-crash-log


📝 Commits (3)

  • 4469914 runtime: print the call chain of a fatal fault
  • 4be6853 runtime: a fatal fault's report names its registers and host, and is kept in a crash log (RT-CRASH-LOG)
  • c2dc711 Merge remote-tracking branch 'upstream/main' into rt-crash-log

📊 Changes

8 files changed (+573 additions, -6 deletions)

View changed files

📝 runtime/CMakeLists.txt (+4 -0)
📝 runtime/README.md (+1 -0)
➕ runtime/src/crash_report.h (+150 -0)
📝 runtime/src/main.cpp (+6 -2)
📝 runtime/src/thread_stacks.cpp (+197 -3)
📝 runtime/src/thread_stacks.h (+7 -0)
➕ runtime/test/crash_report_test.cpp (+87 -0)
📝 runtime/test/thread_stacks_test.cpp (+121 -1)

📄 Description

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


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/ubiquitarianism/leonida/pull/2306 **Author:** [@Tyrannys](https://github.com/Tyrannys) **Created:** 11/26/2026 **Status:** 🔄 Open **Base:** `main` ← **Head:** `rt-crash-log` --- ### 📝 Commits (3) - [`4469914`](https://github.com/ubiquitarianism/leonida/commit/4469914649a0c6c1f4ba0924eb6befade61fff22) runtime: print the call chain of a fatal fault - [`4be6853`](https://github.com/ubiquitarianism/leonida/commit/4be68530268702cd6899a24725d96f7e06b99307) runtime: a fatal fault's report names its registers and host, and is kept in a crash log (RT-CRASH-LOG) - [`c2dc711`](https://github.com/ubiquitarianism/leonida/commit/c2dc7113335f7a0e2122d731b2b3f6a0da59eefe) Merge remote-tracking branch 'upstream/main' into rt-crash-log ### 📊 Changes **8 files changed** (+573 additions, -6 deletions) <details> <summary>View changed files</summary> 📝 `runtime/CMakeLists.txt` (+4 -0) 📝 `runtime/README.md` (+1 -0) ➕ `runtime/src/crash_report.h` (+150 -0) 📝 `runtime/src/main.cpp` (+6 -2) 📝 `runtime/src/thread_stacks.cpp` (+197 -3) 📝 `runtime/src/thread_stacks.h` (+7 -0) ➕ `runtime/test/crash_report_test.cpp` (+87 -0) 📝 `runtime/test/thread_stacks_test.cpp` (+121 -1) </details> ### 📄 Description 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) --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
Sign in to join this conversation.
No labels
bug
pull-request
No milestone
No project
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.

Dependencies

No dependencies set

Reference
starred/leonida#2310
No description provided.