runtime: say so when the title's hang watchdog ends the run (RT-WATCHDOG-FIRED-NOTE) #2156

Closed
github-bot wants to merge 1 commit from github-bot/gh-2156 into main AGit
Owner

@⁠quartz-heron-58 on GitHub · 2026-11-26 00:24 UTC · original
quartz-heron-58:watchdog-fired-note → main · +215 −16 · 4 files · 1 commits · closed without merging

Claimed in the coordination issue as: RT-WATCHDOG-FIRED-NOTE (#1608)

What and why

The retail title runs a hang watchdog: when its main loop has not reported progress for 30 one-second ticks, it calls a crash callback and writes to address 0 on purpose (the comment at the top of runtime/src/main.cpp has described this since LEONIDA_TITLE_WATCHDOG was added). Under the runtime the main loop can stall that long for ordinary reasons, a pipeline build for instance. The log then showed only an access violation writing address 0 in title code, and people take it for a fault of the layer or of whatever happened just before it: #2019 (read as a consequence of two DirectStorage errors), #1915, and my own first boots with input. Each time someone had to explain it by hand.

Now the runtime says it. When the unhandled-exception filter sees that write, it prints once:

[rt] the title's own hang watchdog ended this run: its main loop did not report progress for 30 one-second ticks, so the title called its crash callback and wrote to address 0 on purpose. The access violation that follows is that write, not a fault of its own; what to look at is what kept the main loop busy (pipeline builds, a long wait). LEONIDA_TITLE_WATCHDOG=0 keeps the watchdog kicked

How it is recognised, with nothing main.cpp did not already know:

  • only when the trap instruction is where this build has it (the same byte check LEONIDA_TITLE_WATCHDOG=0 already made; any other build is left alone);
  • the fault is a write to address 0, and either the faulting instruction is the trap itself or the trap's address is on the faulting thread's stack within 128 words of the stack pointer. The second is the usual case: the write happens inside the crash callback, whose return address is the trap (the call is the instruction before it).

The constants and the recognition move from main.cpp to runtime/src/title_watchdog.h as pure functions (trap_present, fired), so they can be tested without Windows or a game file. No new addresses, no behaviour change: the exception goes on to the cache write and the title's filter exactly as before, and LEONIDA_TITLE_WATCHDOG=0 works as it did.

Tested

Windows 11 (26300), MSVC Build Tools 2022, RelWithDebInfo, scripts\build_runtime.ps1 -FetchSdl3 on main c50ed94b3 plus this commit: build exit 0.

  • title_watchdog_test (new, CPU only, a zeroed buffer stands in for the image): 19 checks, 0 failures. ctest title_watchdog and arena_blocks pass.
  • Real boot on an RTX 4080 (NVIDIA 621.24), own 1.0.2.1 package, this branch, foreground pipeline builds, LEONIDA_TITLE_WATCHDOG unset: the last submission report is at 200 s, the title's exception (write to address 0, three title frames, the second one the trap's address) is at 228.8 s, and the log has the new line exactly once, directly before "unhandled exception 0xc0000005: writing the session pipeline cache". No device-loss report in that run. One run.
  • scripts/check_no_game_data.py on the four changed files: clean.

Not run: the whole ctest set; a run with LEONIDA_TITLE_WATCHDOG=0 on this branch (the kick path only changed in where it gets its constants and its build check); Linux/Wine and clang-cl; a build without LEONIDA_VULKAN_DEVICE (the filter does not exist there, so the note does not either).

Seen while testing, not from this change: ctest gameinput_script fails on main c50ed94b3 in an SDL3 build (reported in #1608; it comes from #2098's change to how long a scripted press is held).

GPUs tested: NVIDIA GeForce RTX 4080, driver 621.24, Windows 11 (the real boot above; the unit test needs no GPU)

AI-assisted: yes (Claude Code)

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 rule)

🤖 Generated with Claude Code

**@⁠quartz-heron-58** on GitHub · 2026-11-26 00:24 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/2156) `quartz-heron-58:watchdog-fired-note` → `main` · +215 −16 · 4 files · 1 commits · closed without merging Claimed in the coordination issue as: RT-WATCHDOG-FIRED-NOTE (#1608) ### What and why The retail title runs a hang watchdog: when its main loop has not reported progress for 30 one-second ticks, it calls a crash callback and writes to address 0 on purpose (the comment at the top of `runtime/src/main.cpp` has described this since `LEONIDA_TITLE_WATCHDOG` was added). Under the runtime the main loop can stall that long for ordinary reasons, a pipeline build for instance. The log then showed only an access violation writing address 0 in title code, and people take it for a fault of the layer or of whatever happened just before it: #2019 (read as a consequence of two DirectStorage errors), #1915, and my own first boots with input. Each time someone had to explain it by hand. Now the runtime says it. When the unhandled-exception filter sees that write, it prints once: ```text [rt] the title's own hang watchdog ended this run: its main loop did not report progress for 30 one-second ticks, so the title called its crash callback and wrote to address 0 on purpose. The access violation that follows is that write, not a fault of its own; what to look at is what kept the main loop busy (pipeline builds, a long wait). LEONIDA_TITLE_WATCHDOG=0 keeps the watchdog kicked ``` How it is recognised, with nothing main.cpp did not already know: - only when the trap instruction is where this build has it (the same byte check `LEONIDA_TITLE_WATCHDOG=0` already made; any other build is left alone); - the fault is a write to address 0, and either the faulting instruction is the trap itself or the trap's address is on the faulting thread's stack within 128 words of the stack pointer. The second is the usual case: the write happens inside the crash callback, whose return address is the trap (the call is the instruction before it). The constants and the recognition move from main.cpp to `runtime/src/title_watchdog.h` as pure functions (`trap_present`, `fired`), so they can be tested without Windows or a game file. No new addresses, no behaviour change: the exception goes on to the cache write and the title's filter exactly as before, and `LEONIDA_TITLE_WATCHDOG=0` works as it did. ### Tested Windows 11 (26300), MSVC Build Tools 2022, RelWithDebInfo, `scripts\build_runtime.ps1 -FetchSdl3` on main c50ed94b3 plus this commit: build exit 0. - `title_watchdog_test` (new, CPU only, a zeroed buffer stands in for the image): 19 checks, 0 failures. ctest `title_watchdog` and `arena_blocks` pass. - Real boot on an RTX 4080 (NVIDIA 621.24), own 1.0.2.1 package, this branch, foreground pipeline builds, `LEONIDA_TITLE_WATCHDOG` unset: the last submission report is at 200 s, the title's exception (write to address 0, three title frames, the second one the trap's address) is at 228.8 s, and the log has the new line exactly once, directly before "unhandled exception 0xc0000005: writing the session pipeline cache". No device-loss report in that run. One run. - `scripts/check_no_game_data.py` on the four changed files: clean. Not run: the whole ctest set; a run with `LEONIDA_TITLE_WATCHDOG=0` on this branch (the kick path only changed in where it gets its constants and its build check); Linux/Wine and clang-cl; a build without `LEONIDA_VULKAN_DEVICE` (the filter does not exist there, so the note does not either). Seen while testing, not from this change: ctest `gameinput_script` fails on main c50ed94b3 in an SDL3 build (reported in #1608; it comes from #2098's change to how long a scripted press is held). GPUs tested: NVIDIA GeForce RTX 4080, driver 621.24, Windows 11 (the real boot above; the unit test needs no GPU) AI-assisted: yes (Claude Code) ### 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 rule) 🤖 Generated with [Claude Code](https://claude.com/claude-code)
The retail title's watchdog ends a run whose main loop stalled for 30 s by
calling a crash callback and writing to address 0. The log then showed only an
access violation in title code, which reads as a fault of the layer or of
whatever happened just before (#2019, #1915).

The unhandled-exception filter now recognises that write and prints one line
naming the watchdog, the 30 s window and LEONIDA_TITLE_WATCHDOG=0. It uses what
main.cpp already knew: the verified trap instruction, and its address as the
fault's instruction or as a return address on the faulting thread's stack. The
exception continues as before.

The watchdog's constants and the recognition move to src/title_watchdog.h
(pure, no Windows), with a CPU-only test of 19 cases.

Co-Authored-By: Claude Fable 5.2 <[email protected]>
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 10:20:31 +00:00
Author
Owner

@⁠moffington on GitHub · 2026-11-26 00:53 UTC · original

Checked 9a013f67 on Linux (AMD Ryzen 5 5600X3D, g++ 16.2.1) and Windows/Wine (clang-cl 23.1.3 + xwin SDK 10.0.26100).

  • gta6rt.exe (runtime/src/main.cpp) and title_watchdog_test.exe cross-compiled cleanly with clang-cl + xwin (covering the clang-cl / Linux+Wine build gap noted in the PR).
  • title_watchdog_test: passed all 19 checks (0 failures) on Linux (g++ 16.2.1, RelWithDebInfo and ASan+UBSan -Wall -Wextra -Werror) and under Wine.
  • Code check: report_title_watchdog() in runtime/src/main.cpp guards ContextRecord, NumberParameters >= 2, 8-byte Rsp alignment, and committed readable stack bounds, and uses std::call_once to emit kFiredNote once.
  • Limitations: no retail game boot or live SEH fault in gta6rt.exe under Wine; main.cpp integration is verified by clang-cl compilation and code inspection.

AI-assisted.

**@⁠moffington** on GitHub · 2026-11-26 00:53 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/2156#issuecomment-7179216621) Checked `9a013f67` on Linux (AMD Ryzen 5 5600X3D, `g++ 16.2.1`) and Windows/Wine (`clang-cl 23.1.3` + `xwin` SDK 10.0.26100). - `gta6rt.exe` (`runtime/src/main.cpp`) and `title_watchdog_test.exe` cross-compiled cleanly with `clang-cl` + `xwin` (covering the `clang-cl` / Linux+Wine build gap noted in the PR). - `title_watchdog_test`: passed all 19 checks (`0 failures`) on Linux (`g++ 16.2.1`, RelWithDebInfo and ASan+UBSan `-Wall -Wextra -Werror`) and under Wine. - Code check: `report_title_watchdog()` in `runtime/src/main.cpp` guards `ContextRecord`, `NumberParameters >= 2`, 8-byte `Rsp` alignment, and committed readable stack bounds, and uses `std::call_once` to emit `kFiredNote` once. - Limitations: no retail game boot or live SEH fault in `gta6rt.exe` under Wine; `main.cpp` integration is verified by `clang-cl` compilation and code inspection. AI-assisted.
github-bot closed this pull request 2026-11-27 02:08:59 +00:00
Author
Owner

@⁠quartz-heron-58 on GitHub · 2026-11-27 02:06 UTC · original

Closing this. Since it was opened, main took the watchdog's trap and kick addresses out of the repository (RT-BOOT-COMBINED, LEONIDA_TITLE_WATCHDOG_KICK), and this branch still carries them in runtime/src/main.cpp; reworking it would mean a different change, and the note it adds matters less now that the watchdog can be kept kicked. Thanks @⁠moffington for checking it. AI-assisted (Claude Code).

**@⁠quartz-heron-58** on GitHub · 2026-11-27 02:06 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/2156#issuecomment-7207839972) Closing this. Since it was opened, main took the watchdog's trap and kick addresses out of the repository (RT-BOOT-COMBINED, LEONIDA_TITLE_WATCHDOG_KICK), and this branch still carries them in runtime/src/main.cpp; reworking it would mean a different change, and the note it adds matters less now that the watchdog can be kept kicked. Thanks @⁠moffington for checking it. AI-assisted (Claude Code).

Pull request closed

This discussion has been locked. Commenting is limited to contributors.
No description provided.