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

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

📋 Pull Request Information

Original PR: https://github.com/ubiquitarianism/leonida/pull/2156
Author: @quartz-heron-58
Created: 11/26/2026
Status: 🔄 Open

Base: main ← Head: watchdog-fired-note


📝 Commits (1)

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

📊 Changes

4 files changed (+215 additions, -16 deletions)

View changed files

📝 runtime/CMakeLists.txt (+6 -0)
📝 runtime/src/main.cpp (+53 -16)
➕ runtime/src/title_watchdog.h (+64 -0)
➕ runtime/test/title_watchdog_test.cpp (+92 -0)

📄 Description

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


🔄 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/2156 **Author:** [@quartz-heron-58](https://github.com/quartz-heron-58) **Created:** 11/26/2026 **Status:** 🔄 Open **Base:** `main` ← **Head:** `watchdog-fired-note` --- ### 📝 Commits (1) - [`9a013f6`](https://github.com/ubiquitarianism/leonida/commit/9a013f67dec0adc9e707eb980774be1bdf57b790) runtime: say so when the title's hang watchdog ends the run (RT-WATCHDOG-FIRED-NOTE) ### 📊 Changes **4 files changed** (+215 additions, -16 deletions) <details> <summary>View changed files</summary> 📝 `runtime/CMakeLists.txt` (+6 -0) 📝 `runtime/src/main.cpp` (+53 -16) ➕ `runtime/src/title_watchdog.h` (+64 -0) ➕ `runtime/test/title_watchdog_test.cpp` (+92 -0) </details> ### 📄 Description 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) --- <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#2159
No description provided.