Skip to content

Loader: opt-in VICTORY_NO_WATCHDOG hook for the title's watchdog (build 1.0.2.1) - #454

Open
ruvenesh wants to merge 2 commits into
Marvisak:mainfrom
ruvenesh:loader/opt-in-watchdog-hook
Open

ruvenesh wants to merge 2 commits into
Marvisak:mainfrom
ruvenesh:loader/opt-in-watchdog-hook

Conversation

@ruvenesh

@ruvenesh ruvenesh commented Nov 24, 2026 •

Copy link
Copy Markdown

Adds an opt-in way past the title's own watchdog, for hosts that load much more slowly than the console. Off by default.

What it does

The title ends the process on purpose when its main thread has not advanced for about 30 one-second ticks. It writes to address 0 in two places (analysed in #71 for the first one):

  • +0x23cf683: mov dword ptr [0], imm32 in the handler the watchdog calls.
  • +0x2215c35: mov dword ptr [0], 0; int3 right after the call rax to that handler. The handler is not expected to return, so NOPing only the first site just reaches this one.

With VICTORY_NO_WATCHDOG=1, victory-loader patches the mapped image once, before any title code runs:

  • at +0x2215c27, a short jmp (EB 18) over the call and the fallback fault, to the loop's normal continuation at +0x2215c41;
  • at +0x23cf683, an eleven-byte NOP in place of the handler's fault.

Each patch is applied only if the original BLAKE3 starts with the 1.0.2.1 identity and the exact expected bytes are at the offset. Otherwise it logs a warning and does nothing. Other builds are untouched.

Asset policy

Only per-build offsets and short byte signatures (11 and 7 bytes), which docs/asset-policy.md allows. cargo xtask policy --staged passes on the three files.

Evidence

Linux, Wine 11.0 (GE-Proton11-14, vkd3d-proton 3.2.0), RTX 3060 12 GB, d2a4bae plus a few open shader PRs, scripted menu input. Of 14 world-load runs without the hook, 7 ended with the +0x23cf683 fault, between about 2 and 8 minutes after launch. The other 7 ended in other ways (device removal 3, an NVIDIA driver crash in vkAllocateMemory 2, one silent exit, and one that reached the second fault site above when only the first was patched). Those runs also differed in VKD3D_CONFIG and shader-skip settings, so the 7 is a count and not a controlled rate. With the hook, the process kept running past that point: the run is still going at 14 minutes. It reached the first mission's title card and then the dark first scene, which matches the README's current status.

A stack dump series (8 to 90 s) shows the title's helper thread is alive but sits in one long wait for about 50 s while title-main polls for its reply, so the watchdog is firing on a slow load and not on a missing thread. I have not identified what that wait is for.

Limits

  • Tested on Linux/Wine only. The code is cfg(windows) and I would expect it to behave the same on Windows, but I have not run it there.
  • It hides a stall; it does not fix what is slow. If the stall is a real deadlock, the game will sit there instead of exiting.
  • Only build 1.0.2.1. Another build needs its own offsets.

🤖 Generated with Claude Code

…ld 1.0.2.1)

The title ends the process on purpose when its main thread has not advanced
for about 30 one-second ticks (a write to address 0 at +0x23cf683, with a
second one at +0x2215c35 right after the handler call). On a host much slower
than the console a long load can exceed that window.

With VICTORY_NO_WATCHDOG=1 the loader jumps over the abort site and makes the
handler's fault a NOP. Each patch is applied only if the original BLAKE3
starts with the 1.0.2.1 identity and the exact original bytes are at the
offset; otherwise it logs a warning and does nothing. Off by default.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
@deadkid14

deadkid14 commented Nov 24, 2026 •

Copy link
Copy Markdown

Tested this together with #177 on d2a4bae: RTX 5070 Ti, driver 620.73.04, GE-Proton11-14's wine run directly, --features diagnostics, Series X files, menus driven by VICTORY_KEYS. Both hooks apply (applied=2) and there is no fault. On this setup, though, the stall does not recover:

  • In three world loads, the frames stop and never resume (I watched for 10+ min, GPU at 0 %). Without a warm shader cache the frames stopped about 2 min after the first mesh pipeline (frame 1352). With a warm cache they stopped after about 40-45 s (frames 1394 and 1249).
  • title-main sits in the wait the watchdog was guarding: +0x56a0d ← +0x23cf735 ← +0x8126a7 ← … ← +0x56a1e5a (from victory_loader::windows::spawn_main).
  • On our side nothing is busy. The DirectStorage workers (dstorage.rs:448), the pipeline makers (idle on their queue) and the XAsync pool are all waiting, and so are vkd3d-proton's threads. The only title thread that showed title code on top in an earlier sample (+0x4ddfdcd, +0x4de35a0) was idle by the third sample.
  • Adding GPU: copy into title memory without asking for its region first #322 changes nothing. It does fix Wine/vkd3d: deferred uploads are skipped because VirtualQuery() reports mapped memory as MEM_FREE #128's buffer_data_reaches_the_host_texture under Wine here, but the hang has the same stacks and timing.

Your RTX 3060 run got past this point. Which open PRs did you have applied on top of d2a4bae? I can try the same set on this card. I can also share the full winedbg bt all dumps.

AI-assisted: Claude Code ran the builds and tests on my machine, read the logs and wrote this comment; posted at my request.

@mercuryVM mercuryVM left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tested d2c93fa on Windows 11, RTX 5070, MSVC: cargo test --workspace --no-fail-fast passes (264 passed, 0 failed). Not tested in game, since I have no game package. With the variable unset the new code is never reached, which is what the test run covers.

I read the patching code by hand first, since it rewrites title code:

  • It only touches the just-mapped title image, before title code runs, gated on the env var, the build hash prefix and an exact byte match at each RVA. The protection is restored and the instruction cache flushed. Nothing else in the process or system is touched.
  • The jump target adds up: 0x2215c27 + 2 + 0x18 = 0x2215c41. The patch and the expected bytes are the same length, and both are a whole number of instructions.
  • The hash is checked before any read at base + rva, so other builds never read out of bounds.

Small points:

  • std::env::var_os(..).is_some() enables the hook for any value, including VICTORY_NO_WATCHDOG=0. The description says =1. Checking for "1" would avoid surprises.
  • The second VirtualProtect (restore) result is ignored. That is fine in practice, but a failure would leave the pages RWX without a log line.
  • Disabling the watchdog turns a fast crash into a possible silent hang for genuinely stuck loads. Since it is opt-in, I think that is an acceptable trade, and the info log line makes it visible.

AI-assisted (Claude Code).

mercuryVM added a commit to mercuryVM/VIctory that referenced this pull request Nov 24, 2026
…ok for the title's watchdog (build 1.0.2.1)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
r4tedx added a commit to r4tedx/VIctory that referenced this pull request Nov 24, 2026
…ild 1.0.2.1)

ruvenesh's Marvisak#454: with VICTORY_NO_WATCHDOG set, the loader patches the
two places where the title's watchdog ends the process, in build
1.0.2.1 only (hash prefix and exact bytes checked). Without the
variable the new code is not reached: its one call site, in
victory-loader's `load`, is behind `var_os(..).is_some()`.

No conflict.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
r4tedx added a commit to r4tedx/VIctory that referenced this pull request Nov 24, 2026
Seven more upstream PRs are in (Marvisak#493, Marvisak#483, Marvisak#206, Marvisak#469, Marvisak#459, Marvisak#454,
Marvisak#579) and the wave64 stack is at Marvisak#439's head 965ce30. Records how each
was combined with what the tree had, that a capped view heap keeps
2^18 dynamic slots and why, Marvisak#189 and Marvisak#578 as left out, and a new
section with testers' reports from the title: the set without the
world-entry hang on three NVIDIA cards and how this tree differs from
it, VICTORY_SKIP_WAVE64 as the switch to try, and Marvisak#136 bisected as
making every frame black.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
@deadkid14

deadkid14 commented Nov 24, 2026 •

Copy link
Copy Markdown

Correction to my comment above: the stall I reported here was not a title-side deadlock. The kernel log for those runs shows Xid 13 … Graphics SM Warp Exception … MMU Fault from title-main: the GPU faulted, so title-main waited forever on work that would never finish. That is the NVIDIA raw-access-chain fault from #542 (see #144).

With VKD3D_DISABLE_EXTENSIONS=VK_NV_raw_access_chains and this PR, the same machine runs past that point. With wave64 handled (#189 or #579), it stays in the world for 10+ minutes with no fault and reaches player control. So on this setup #454 does what it says, and I have no evidence against it.

AI-assisted: Claude Code ran the builds and tests on my machine, read the logs and wrote this comment; posted at my request.

@iurysf

iurysf commented Nov 24, 2026

Copy link
Copy Markdown

Windows data point for the first fault site: on an RTX 4070 (Windows 11, native D3D12, driver 32.0.16.2101, title 1.0.2.1), 7 of 7 runs with VICTORY_D3D12_DEBUG=1 + VICTORY_D3D12_GBV=1 ended at:

unhandled exception 0xc0000005 at victory-image-b99f876b74d4a77f.dll+0x23cf683 (write 0x0)

Those runs were on main d2a4bae with #493 + #483, and some added #233, #581 or #588. They ended 131–186 s after launch, always before the world. GPU-based validation slows the GPU without tripping the TDR, much like the TdrDelay=60 runs in #97, which hit the same address. So it fits your reading that the watchdog fires on a slow load. On Windows this is what has kept us from collecting validation counts inside the world.

I'll run this PR on Windows (GBV on, then off) and report whether the process gets past that point and how far it gets.

AI-assisted.

edsuuu referenced this pull request in edsuuu/VI-BR-PORT Nov 24, 2026
…PR #454)

Ports PR #454 (d2c93fa) unchanged. The title ends the process when its
main thread has not advanced for about 30 one-second ticks; slow world
frames on this host can trip it. With VICTORY_NO_WATCHDOG=1 the loader
jumps over the abort and makes the handler's fault a NOP, only on the
Series X 1.0.2.1 build and only where the exact original bytes are found.
Off by default.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
github-actions Bot added a commit to KevinPratap/VIctory that referenced this pull request Nov 24, 2026
1bugproof pushed a commit to 1984742628/VIctory that referenced this pull request Nov 24, 2026
…on slow frames (port of Marvisak/VIctory Marvisak#454)

Byte-checked patches for one build only; off by default.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

Copy link
Copy Markdown
Owner

Automated triage for the maintainers.

Needs work: needs the maintainer's decision. This adds an opt-in VICTORY_NO_WATCHDOG that patches two sites in the title's code for build 1.0.2.1 (disarm_watchdog in crates/victory-loader/src/hooks.rs, called from load in windows.rs). The checks look right: it patches only when the build hash matches and the original bytes are exactly as expected, the EB 18 jump lands on +0x2215c41, and the replacement is a valid 11-byte NOP; the checked bytes are short signatures, which docs/asset-policy.md allows. Whether to patch title code at all is the maintainer's call. Note from the thread: in 3 of 6 runs the stall was a lookup spinning forever in the title itself, so with the hook on the game hangs instead of exiting; main already has VICTORY_POKE for a watchdog tick. If accepted, please add the variable to the README's diagnostics table.

CI: no check runs on the head commit.


Generated by Claude Code

@AgneyaK

AgneyaK commented Nov 25, 2026 •

Copy link
Copy Markdown
Contributor

For the maintainer's decision: main can already do this without patching code. VICTORY_POKE (apps/victory/src/run.rs, diagnostics build) was added for exactly this watchdog ("runs on through slower frames with its tick flag poked"), but no address is documented. The byte is 0x71B6330:

VICTORY_POKE=71B6330:1

Why that byte, from image b99f876b… (base 0x140000000). Full decode on #630:

  • The watchdog thread (+0x2215a60) wakes once a second. If byte [+0x71b6330] is set, it re-arms and checks nothing. The title sets it itself, in its event handler +0x22159c0, on event type 0x24, and clears it on 0x25. So poking it to 1 is the title's own pause, not a code change.
  • Without the pause, the countdown is 30 wakes with no heartbeat (+0x22159f0 writing +0x71b6338), then the kill.
  • All three null stores are this one watchdog. +0x2215c35 and +0x2215da9 are its two kill paths. +0x23cf683 is in +0x23cf620, its callback. That function's only reference is the lea at +0x23cf6f7 that registers it into +0x71b6348 (setter +0x22161f0), and +0x71b6348 is read only at the two kill paths. So pausing the watchdog avoids all three sites, the same two that this PR patches plus +0x2215da9.
  • 0x71B6331 (the re-arm byte) would also reset the countdown, but in the watchdog's table mode it still walks the table. 0x71B6330 skips both.

Run-time evidence: not yet shown (corrected). I first wrote that a run with the poke had no watchdog kill. That run (Windows 11, RTX 3050 laptop, 70564ae) did go on to 80 s, but its NVIDIA device removal (#1754) came only 28 s after XUserAddAsync, before a 30 s countdown could have run out. So it doesn't show that the poke prevents the kill. The run without the poke was killed at +0x2215c35 31 s after XUserAddAsync. What's above is from the disassembly. A clean A/B, holding title-main suspended for 40 s with and without the poke, is still to be run.

The caveat in this PR's Limits holds for the poke too: it hides a stall and doesn't fix it. A one-line README entry naming the address may be all that's needed instead of a loader patch.

AI use: Claude Code (Claude Opus 5.5) disassembled the image locally and wrote this; the two runs are as described.

@AgneyaK

AgneyaK commented Nov 25, 2026

Copy link
Copy Markdown
Contributor

Correction to my comment above (edited): the run I cited for VICTORY_POKE=71B6330:1 ended in the NVIDIA removal 28 s after XUserAddAsync, before a 30 s watchdog could fire, so it doesn't show that the poke prevents the kill. The pause-byte reading is from the disassembly only. A controlled A/B is still to come.

AI use: Claude Code (Claude Opus 5.5).

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.