watch: a late lock-free write fault can undo a guard taken since (access violation) #817
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
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 Machad3x on 2026-11-28T06:52:52Z.
Summary: a race in the lock-free write-fault path of
crates/victory-gpu/src/watch.rs(fromf5bde6b5, on by default). It can leave a guarded block read-only with itsPROTECTEDbit cleared. The title's next write to that block is then an access violation that no handler takes.Sequence:
PROTECTED, opens the block, and the opening is settled.PROTECTEDbefore A's opening was settled. It reachesopen_unlockedonly after that, finds the block already writable, and still queues its own opening.PROTECTED, but the memory stays read-only.Where we saw it: segfaults in the victory-gpu unit tests (the land, many-askers and refresh tests), about 1 run in 7 on tn1 main 3c142d49. In the game this would show as a crash on a title write. On tn1 main this also caused a test hang, in
what_the_title_puts_in_beside_a_guard_is_toldlooping onput_besidereturningCannot. That hang is a separate, test-only bug: two tests released a view while still holding the mapping-change lock.Fix on our side:
open_unlockedrecords whether its ownVirtualProtectmade the block writable.settleleaves an entry that did not make it writable alone, apart from itsOPENINGandTOLDbits. Regression test:a_late_fault_leaves_the_guard_taken_since. After the fix we ran the tests 80 times on tn1 main and 40 times on our batch, with no segfaults. I will link the commit once it is pushed to our fork (Machad3x/VIctory-nvidia-RTX).Setup: RTX 3080 Ti, driver 621.40, Windows 11 Pro build 26300, Ryzen 7 5700X,
cargo test -p victory-gpu --profile diag --lib.Imported from trustno1-coder/VIctory-NVIDIA. Originally posted by github-actions[bot] on 2026-11-28T06:53:01Z.
Please attach both logs from the run that went wrong. Without them we can only guess. Paste
%LOCALAPPDATA%into the address bar of File Explorer to get there.%LOCALAPPDATA%\victory\logs\: the newestvictory-nvidia-play-<date>-<time>-<number>.log(fromvictory.exe) orvictory-nvidia-<date>-<time>.log(from the script launcher). The window shows its path at the start, on the lineLog: ....%LOCALAPPDATA%\VIctory\data\7952987A\crashes.log, and, if there is one from that run, the newestvictory-<date>-<time>-<number>.crash.login%LOCALAPPDATA%\VIctory\data\7952987A\temp\.Also say which GPU, Windows version (10 or 11)
Imported from trustno1-coder/VIctory-NVIDIA. Originally posted by Machad3x on 2026-11-28T07:09:11Z.
Fix pushed to our fork:
github.com/Machad3x/VIctory-nvidia-RTX@3175c5dc(regression testa_late_fault_leaves_the_guard_taken_since). The test-only hang fix isgithub.com/Machad3x/VIctory-nvidia-RTX@df65d657.Imported from trustno1-coder/VIctory-NVIDIA. Originally posted by yeedgrthfgv on 2026-11-28T08:07:18Z.
Thanks for finding this and for the fix. I would like to send a pull request that makes VICTORY_FAULT_UNLOCKED easy to try: your race fix (3175c5dc) and your test fixes (df65d657) cherry picked with you kept as the author, plus an F1 menu line for the switch, still off by default.
I tested it on a Ryzen 5 9600X with an RTX 5080: no crash with the switch on, and the wait for the guards lock went from about 45 ms to about 10 ms a frame across all threads. The frame rate did not change on my PC.
Is that OK with you, or would you rather send your fix yourself? If you send it, I will only add the menu line and my numbers on top.