Loader: opt-in VICTORY_NO_WATCHDOG hook for the title's watchdog (build 1.0.2.1) #454
No reviewers
Labels
No labels
accessibility
area: build
area: formats
area: gpu
area: loader
area: runtime
area: shader
bug
documentation
duplicate
enhancement
good first issue
gpu: amd
gpu: intel
gpu: nvidia
help wanted
host: wine
invalid
out of scope
question
request
run report
triage: confirmed
triage: has patch
triage: merge candidate
triage: needs info
triage: needs rebase
triage: needs work
triage: proposed close
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/Marvisak--VIctory!454
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-454"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
@ruvenesh on GitHub · 2026-11-24 03:37 UTC · original
ruvenesh:loader/opt-in-watchdog-hook→main· +95 −0 · 3 files · 2 commits · openAdds 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], imm32in the handler the watchdog calls.+0x2215c35:mov dword ptr [0], 0; int3right after thecall raxto 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-loaderpatches the mapped image once, before any title code runs:+0x2215c27, a shortjmp(EB 18) over the call and the fallback fault, to the loop's normal continuation at+0x2215c41;+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.mdallows.cargo xtask policy --stagedpasses on the three files.Evidence
Linux, Wine 11.0 (GE-Proton11-14, vkd3d-proton 3.2.0), RTX 3060 12 GB,
d2a4baeplus a few open shader PRs, scripted menu input. Of 14 world-load runs without the hook, 7 ended with the+0x23cf683fault, between about 2 and 8 minutes after launch. The other 7 ended in other ways (device removal 3, an NVIDIA driver crash invkAllocateMemory2, one silent exit, and one that reached the second fault site above when only the first was patched). Those runs also differed inVKD3D_CONFIGand 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
cfg(windows)and I would expect it to behave the same on Windows, but I have not run it there.🤖 Generated with Claude Code
@iurysf on GitHub · 2026-11-24 09:08 UTC · original
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=1ended at:Those runs were on main
d2a4baewith #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 theTdrDelay=60runs 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.
@Exorion1er on GitHub · 2026-11-24 09:33 UTC · original
Works under Proton: GE-Proton11-12's Wine, vkd3d-proton 3.2.0, RX 9070 XT RADV, with #190, #493 and #579 on
main.title watchdog hooks (VICTORY_NO_WATCHDOG) applied=2, and runs went about 7 minutes into the world, reaching the start of gameplay. They ended on the title's ownint3at+0x63966f(the pool free-list case from #597), not on the watchdog. On this card I saw no GPU fault in those runs, so it didn't hide one.AI-assisted (Claude Code).
@iurysf on GitHub · 2026-11-24 09:53 UTC · original
First Windows run: it works. Windows 11 (26300), RTX 4070, driver 32.0.16.2101, title 1.0.2.1. This PR on top of #493 + #483 merges cleanly.
VICTORY_NO_WATCHDOG=1,DRED=1, default loop limit.hook applied what="watchdog: skip the call and the fallback fault",hook applied what="watchdog: handler's deliberate fault", thentitle watchdog hooks (VICTORY_NO_WATCHDOG) applied=2. A second image logsapplied=0, as expected, and nothing logs "hook skipped".+0x23cf683write. There was no title exception, no Breakpad upload, nocrashes.logand no device removal. It reached the world at 105 s. Under GBV the world is barely usable, though: the first world frame took 17 s, and from ~125 s the frame counter stays at the same values while the process keeps running with stable memory. So we still get no validation counts deep in the world, but GBV at least gets past the load now.AI-assisted.
@AugustoZFJ on GitHub · 2026-11-24 09:53 UTC · original
Tested on Linux with an RX 6900 XT (RADV 26.2.6, GE-Proton11-14, kernel 7.3.5) on
maind2a4bae+ #493 + this PR (d2c93fa), diag build,VICTORY_NO_WATCHDOG=1. Each run starts from the same save and shader cache, and I stop it after 600 s in the world.Both hooks apply (
title watchdog hooks (VICTORY_NO_WATCHDOG) applied=2).Without this PR, one of two runs on
main+ #493 ended at+0x2215c35after 32 s with no frame. With the hook, the first two runs didn't end there and one reached the 600 s limit. That says little about the hook, though: the longest gap between log lines in those two was 15 s, so the 30 s check wouldn't have fired anyway.Then the stall came back twice with the hook on, and it doesn't end. One run was the same build with
VICTORY_STACKSevery 15 s. Frames stopped 134 s into the world and the process sat there for the 224 s left on the run's clock. The other was r4tedx's tester tree at 46ca402, which has this PR in it: frames stopped at 135 s and nothing more came for 465 s. The 32 s stall without the hook began at 136 s. So it's one spot in the opening, and three of my six scripted runs stalled there.It isn't the GPU here, unlike what deadkid14 found on NVIDIA. The kernel log is empty for all three runs, and vkd3d-proton's queue and fence threads are idle in every dump.
The 16 dumps taken during the stall are identical:
+0x56a0dcalled from+0x23cf735, from+0x8126a7), which is where the dumps before the stall have it. It's one call earlier, at+0x509898d(from+0x7b5a9d,+0x21b6d0d,+0x81269b), in aWaitForSingleObjectwith no timeout.+0x55bfc39and+0x55af92f. All three sites set a waiter bit on a count of outstanding work and wait on an event if the count wasn't zero.+0x23cf104, which I take to be the helper thread from your description, is at+0x43c3d5d, waiting on the event of a thread it handed work to. That one is at+0x527bd2. It bumps a counter in each object of a list and waits on the object's handle when the counter was already positive, which reads like taking a lock somebody else holds.So on this machine it's title threads waiting on each other, the real deadlock case from your Limits. The hook does what it says, but in three runs out of six it would trade the watchdog's exit for a hang. I don't know yet which handle never gets signalled. I've written a local trace of who creates and signals each handle the title waits on, and that's my next run.
Two of the four measured runs with #493 ended on the
int3at+0x63966finstead, one with the hook and one without, 442 s and 508 s into the world. It's the one Exorion1er got, the pool case from #597. No stall before it in either run.Indirect execution was off in all of these (#170). With #493 in there was no device removal in any run.
@AugustoZFJ on GitHub · 2026-11-24 11:54 UTC · original
Correction to my comment above. The stall isn't title threads waiting on each other. One job worker never waits at all: it spins in a lookup, and everything else queues up behind it.
That comes from three more stalled runs (three of six again, this time on
main8e79c80andffe310ewith #493 and this PR), a local trace of the title's event and semaphore calls, and a register dump for threads caught in title code.+0x50eb826or a few instructions before it, called from+0x31962,+0x317fd,+0x25d801b, with no system call above it. I missed it the first time because my script only compared stacks that were identical byte for byte. In two of the runs a second worker is in the same loop.0xc8084aand the table held0x88084a: same pool, same slot, one bit apart. So an entry was added for that slot, and the slot's word changed before the lookup built its key. The table was fine otherwise. It was the one the threads were probing, 426 entries in 2,048 slots, not rebuilt since loading.+0x8d7a9b0, so the job that clears the table (the wait at+0x55bfc39from my first comment) never gets to run, title-main waits on job completions, and the other workers sit idle.No VIctory thread is involved and none of the stuck handles is one VIctory signals, so I read it as a race in the title that frames of about 2 s open up (0.4 to 0.6 fps here). I haven't found what changes the slot in between. For this PR nothing changes from what I said before: with the hook the process hangs at that point, and without it the watchdog ends it after 30 s.
@DaviTostes on GitHub · 2026-11-24 13:41 UTC · original
Stack test with the game on the build you target (1.0.2.1), Linux/Wine:
main ffe310e+ #783 + #388 + #282 + this PR, release MSVC, RX 9060 XT (RDNA4/RADV 26.3.1), Wine 11.22, DXVK 3.1.1, vkd3d-proton 3.2.0.With
VICTORY_NO_WATCHDOG=1the title no longer ends in its null-write/hang-check path: after the #774RtlReleaseSRWLockExclusivemessages (~3 min into the world) the process stays alive with no new frames. So the hook does what it says; the freeze itself is still there.Not tested: a run without the hook on the same build/save for a direct A/B, and Windows.
@Yaekai on GitHub · 2026-11-24 16:13 UTC · original
Independent test & review on Windows 11 + GTA VI
1.0.2.1(b99f876b74d4a77f, Rust 1.98.1) at headd2c93fa:cargo test -p victory-loader --lib: 18 passed, 0 failed;cargo clippy -p victory-loader -- -D warnings: 0 warnings.VICTORY_NO_WATCHDOG=1: both patches apply cleanly and prevent the 30 s watchdog fault at+0x23cf683during heavy world loading.crates/victory-loader/src/windows.rs:std::env::var_os(NO_WATCHDOG_ENV).is_some()treatsVICTORY_NO_WATCHDOG=0or""as enabled;is_some_and(|v| !v.is_empty() && v != "0")is safer.@deadkid14 on GitHub · 2026-11-24 04:32 UTC · original · edited 2026-11-24 17:51 UTC
Tested this together with #177 on
d2a4bae: RTX 5070 Ti, driver 620.73.04, GE-Proton11-14'swinerun directly,--features diagnostics, Series X files, menus driven byVICTORY_KEYS. Both hooks apply (applied=2) and there is no fault. On this setup, though, the stall does not recover:+0x56a0d←+0x23cf735←+0x8126a7← … ←+0x56a1e5a(fromvictory_loader::windows::spawn_main).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.buffer_data_reaches_the_host_textureunder 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 fullwinedbg bt alldumps.AI-assisted: Claude Code ran the builds and tests on my machine, read the logs and wrote this comment; posted at my request.
@deadkid14 on GitHub · 2026-11-24 07:18 UTC · original · edited 2026-11-24 17:51 UTC
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 Faultfromtitle-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_chainsand 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.
@Marvisak on GitHub · 2026-11-25 00:26 UTC · original
Automated triage for the maintainers.
Needs work: needs the maintainer's decision. This adds an opt-in
VICTORY_NO_WATCHDOGthat patches two sites in the title's code for build 1.0.2.1 (disarm_watchdogincrates/victory-loader/src/hooks.rs, called fromloadinwindows.rs). The checks look right: it patches only when the build hash matches and the original bytes are exactly as expected, theEB 18jump lands on+0x2215c41, and the replacement is a valid 11-byte NOP; the checked bytes are short signatures, whichdocs/asset-policy.mdallows. 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 hasVICTORY_POKEfor 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 on GitHub · 2026-11-25 05:28 UTC · original · edited 2026-11-25 06:21 UTC
For the maintainer's decision:
maincan 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 is0x71B6330:Why that byte, from image
b99f876b…(base0x140000000). Full decode on #630:+0x2215a60) wakes once a second. Ifbyte [+0x71b6330]is set, it re-arms and checks nothing. The title sets it itself, in its event handler+0x22159c0, on event type0x24, and clears it on0x25. So poking it to 1 is the title's own pause, not a code change.+0x22159f0writing+0x71b6338), then the kill.+0x2215c35and+0x2215da9are its two kill paths.+0x23cf683is in+0x23cf620, its callback. That function's only reference is theleaat+0x23cf6f7that registers it into+0x71b6348(setter+0x22161f0), and+0x71b6348is 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.0x71B6330skips 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 afterXUserAddAsync, 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+0x2215c3531 s afterXUserAddAsync. What's above is from the disassembly. A clean A/B, holdingtitle-mainsuspended 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 on GitHub · 2026-11-25 06:21 UTC · original
Correction to my comment above (edited): the run I cited for
VICTORY_POKE=71B6330:1ended in the NVIDIA removal 28 s afterXUserAddAsync, 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).
@mercuryVM on GitHub · 2026-11-24 05:53 UTC · original · approved these changes
Tested
d2c93faon Windows 11, RTX 5070, MSVC:cargo test --workspace --no-fail-fastpasses (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:
0x2215c27 + 2 + 0x18 = 0x2215c41. The patch and the expected bytes are the same length, and both are a whole number of instructions.base + rva, so other builds never read out of bounds.Small points:
std::env::var_os(..).is_some()enables the hook for any value, includingVICTORY_NO_WATCHDOG=0. The description says=1. Checking for"1"would avoid surprises.VirtualProtect(restore) result is ignored. That is fine in practice, but a failure would leave the pages RWX without a log line.AI-assisted (Claude Code).
@catminou4 on GitHub · 2026-11-24 12:38 UTC · original · reviewed
Test-merge with current main (
ffe310e) is clean.cargo test -p victory-loader --locked(macOS arm64, rustc 1.98.1) → 0 passed / 3 failed — but the same 3 fail on unmodified main (prepare::tests::{patches_own_test_binary, keeps_iat_slots_when_import_size_excludes_the_terminator, file_name_is_stable_per_build}), so this PR introduces no regression; they look like the same Mach-O-vs-PE platform issue I flagged for victory-pe on #529 (tests parsing the test executable as a PE).The
VICTORY_NO_WATCHDOGopt-in hook itself is loader-side and platform-independent, so it's worth a look on Windows where the loader tests actually run. I couldn't exercise the new path here beyond compilation.@crissuper20 on GitHub · 2026-11-26 12:06 UTC · original
Long-run data on a GTX 1650 (4 GB), i5-4690, 16 GB, diag build. Base: fxceless/victory-fork
be721d5, which doesn't carry this PR.85c04d1,VICTORY_NO_WATCHDOG=1With it, the lit opening cutscene plays on this card. It merged cleanly onto that fork.
AI-assisted (Claude Code); measured on my own machine.
View command line instructions
Checkout
From your project repository, check out a new branch and test the changes.Merge
Merge the changes and update on Forgejo.