Watch: a late lock-free fault no longer undoes the guard taken since (#817) #834
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/834"
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?
Imported from trustno1-coder/VIctory-NVIDIA. Originally posted by GRG-DA on 2026-11-28T07:33:54Z.
Fixes #817.
Why
A write fault can check
PROTECTED, then reachopen_unlockedonly after another fault has opened the block and that opening was settled. It finds the block already writable, but still queues anOpenedrecord. A refresh that looked at the block earlier can guard it again in the meantime (read-only, protected, clean). The nextsettle()takes that stale record, removes the block from the guards and clearsPROTECTEDwhile the memory stays read-only. The title's next write there is an access violation no handler takes — seen as segfaults in thevictory-gpuunit tests (land, many-askers, refresh) in roughly 1 run in 7.What
open_unlockedrecordstook = !(done && old == PAGE_READWRITE): whether that fault's ownVirtualProtectmade the block writable. A failedVirtualProtectstill takes the genuine path and the locked fallback.settle()leaves a stale entry's guard alone. It clears only that entry'sTOLDbits andOPENING, sounsettled()drains and the newer guard, its clean notes,PROTECTED,PUBLISHED,BESIDEandopened_atall survive.a_late_fault_leaves_the_guard_taken_since: guards two views, queues a stale entry that tells the other view as written, settles, checks thatTOLD/OPENINGdrain while both views keep their guard notes andPROTECTEDbit with the block still read-only, then checks that a genuine fault opens it and it is reported once at the next asking. The non-emptyothersmeans theTOLD.clearbranch of the fix is covered too.Credit
The root cause and fix are from @Machad3x (issue #817), who published the fix as commit
3175c5dcinMachad3x/VIctory-nvidia-RTXbut had not opened a pull request here. This is a port of that commit onto currentmain, with a longer regression test.Checks
others/TOLDcoverage was added.cargo test -p victory-gpu --lib watch: 48 passed.cargo test -p victory-gpu --lib: 454 passed, 0 failed on five consecutive runs. The single failure on the first run is a source-documented flake that also reproduces on unmodifiedmain.watchmodule 100×: 4 failures, all in pre-existing flaky tests; unmodifiedmainunder the same loop: 3 failures (the source predicts 1–4 per 100).mainatassert!(g.protected.contains(b) && g.clean.contains(b)), so it detects the bug rather than merely describing it.cargo clippy -p victory-gpu --all-targets -- -D warnings: only the pre-existingclippy::manual_is_multiple_ofatshadow.rs:1708in an untouched file; with that lint allowed, no findings in changed lines.cargo xtask policy: 294 files ok.git diff --check: clean. Nocargo fmt(the tree is not rustfmt-clean).Not covered
63b902fin this environment,cargo test --workspace --lockedalready fails atvictory-loader'sconsole_insn::tests::a_clzero_loop_becomes_plain_stores. That is pre-existing and unrelated to this change.Implemented with OpenCode using parallel agents for issue scouting, contributor-convention mapping, invariant auditing, implementation and independent review.
Imported from trustno1-coder/VIctory-NVIDIA. Originally posted by POMXARK on 2026-11-28T08:05:31Z.
Validated this fix in unit tests and a full 20-minute 3D run on Windows 11 with
VICTORY_FAULT_UNLOCKED=1enabled by default — PASS (0 errors, 0 exceptions, 0 frames >=250 ms across 20 minutes).Setup
tearing=true),VICTORY_FAULT_UNLOCKED=1(via PR #516), default4 MiBwindows,VICTORY_GPU_BCPACK=0,VICTORY_WAIT_RESIDENT=0,VICTORY_TEXTURE_ROOM_PERCENT=70,VICTORY_LAND_SKIP=1.v2026.11.27.10(8fc2254) + AVX2/ThinLTO + PR #516 + PR #340 + PR #81 + PR #666 + AVX2Shadow::take/ PR #498 + PR #801 (e6397aa). PR #834 applied cleanly with zero conflicts.cargo test --locked -p victory-gpu --lib -- watch:: --test-threads=1(VICTORY_D3D12_WARP=1) — 49/49 passed (1.59 s), includinga_late_fault_leaves_the_guard_taken_since.20-Minute Live 3D Validation Results
v22_r11_pr834_20m,1200 s)0 / 0 / 00 / 0 / 0(worst 3D frame across 20m:210.1 ms)frame_times(3D,n=1049)63.8 msmed /83.1 msp95 /93.8 msp991k–4k:18.80 FPS(n=96),4k–7k:15.80 FPS(n=66),7k–10k:10.90 FPS(n=37),>=10k:9.30 FPS(n=8)hw.csv)DedMax 11,134 MB,SharedMax 9,680 MB(final6,482 MB),CommitMax 30,317 MB,MinFreeC 10.90 GB,Resp 329/330No regressions or rendering anomalies observed under continuous lock-free write-watch fault load.
Imported from trustno1-coder/VIctory-NVIDIA. Originally posted by yeedgrthfgv on 2026-11-28T08:20:15Z.
Tested this fix (same change as Machad3x's 3175c5dc) on a Ryzen 5 9600X (6 cores) with an RTX 5080, Windows 11, Series X 4K output, DLSS Performance, frame generation 2x, THIN on, opening prison scene, about 4,800 draws a frame.
One diagnostics run with VICTORY_AB=30,VICTORY_FAULT_UNLOCKED, so the switch flipped every 30 s in the same scene. Per frame, all threads:
So the switch takes about 35 to 40 ms a frame of waiting off the helper threads. The frame rate did not move on this PC: settled phases were 42.2 ms a frame both ways, and two 4 minute release runs gave 23.1 fps off and 23.5 fps on (within the run to run spread). Here the frame is set by the submitting thread, so the freed time does not show. It may matter more on CPUs with fewer free cores.
No crash, no access violation and no warning with the switch on, both in the run where it flipped 13 times and in a 4 minute run with it on throughout.
Also from the same fork, df65d657 fixes the watch tests that hang or fail together (on this PC the full victory-gpu lib suite failed 19 of 60 runs on
63b902f, 1 of 60 with both commits). Might be worth taking with this one.Imported from trustno1-coder/VIctory-NVIDIA. Originally posted by jptorres96 on 2026-11-28T09:16:44Z.
The new
a_late_fault_leaves_the_guard_taken_sincepasses, and the fullvictory-gpulib suite (454 tests) is green.Env: RTX 4080 SUPER (driver 621.01), Ryzen 5 5600X, Windows build 26300, rustc 1.98.1, DXC 1.9.2609.5 (
VICTORY_DXIL),--test-threads=1.VICTORY_INDIRECT_REST=1set to sidestep main's two indirect budget-test failures (fixed in #67), unrelated to this PR.