Repository navigation
Conversation
A write fault that checked PROTECTED, and reached open_unlocked only after another fault had opened the block and that was settled, found the block writable already but queued its opening anyway. A refresh that had looked at the block before guarded it again (read-only, protected, clean); the next settle then took the stale entry, removed the block from the guards and cleared PROTECTED while the memory stayed read-only. The title's next write there was an access violation no handler took. open_unlocked records took = !(done && old == PAGE_READWRITE): whether that fault's own VirtualProtect made the block writable. settle leaves an entry that did not take the block alone, apart from its OPENING and TOLD bits, so the guard taken since survives. Test a_late_fault_leaves_the_guard_taken_since. Reported in trustno1-coder#817 by @Machad3x, who published the fix as commit 3175c5dc in Machad3x/VIctory-nvidia-RTX. Ported onto current main with a longer test.
The regression test queued a stale entry with no `others`, so the `TOLD.clear(other)` branch added by the fix was never exercised. Let the entry tell the other view as written, as `open_unlocked` does, and assert that after settling TOLD and OPENING are gone while both views keep their guard notes and PROTECTED bit. On the unfixed code the other view's notes are removed, so this also detects the bug on that path.
|
Validated this fix in unit tests and a full 20-minute 3D run on Windows 11 with Setup
20-Minute Live 3D Validation Results
No regressions or rendering anomalies observed under continuous lock-free write-watch fault load. |
|
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. |
|
The new Env: RTX 4080 SUPER (driver 621.01), Ryzen 5 5600X, Windows build 26300, rustc 1.98.1, DXC 1.9.2609.5 ( |
… guard taken since, trustno1-coder#817)
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.