Skip to content

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

Closed
quartz-heron-58 wants to merge 1 commit into
ProjectLeonida:mainfrom
quartz-heron-58:watchdog-fired-note
Closed

quartz-heron-58 wants to merge 1 commit into
ProjectLeonida:mainfrom
quartz-heron-58:watchdog-fired-note

Conversation

@quartz-heron-58

Copy link
Copy Markdown
Contributor

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 c50ed94 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 c50ed94 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

…DOG-FIRED-NOTE)

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 (ProjectLeonida#2019, ProjectLeonida#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 <noreply@anthropic.com>
@moffington

Copy link
Copy Markdown
Contributor

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-actions github-actions Bot added the needs rebase Conflicts with the base branch: rebase it on main label Nov 26, 2026
@quartz-heron-58

Copy link
Copy Markdown
Contributor Author

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

needs rebase Conflicts with the base branch: rebase it on main

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants