VICTORY_FRONT_SIFT / VICTORY_FLUSH_SIFT: a span dropped before the write-watch asking may miss a write that lands before the copy (found by reading, not seen in play) #3240

Open
opened 2026-11-29 20:57:29 +00:00 by github-bot · 1 comment
Owner

@⁠CuteBooty on GitHub · 2026-11-29 20:57 UTC · original

Not seen in play. No build or test was run for this. It was found by reading the source at main 829188e96, and the reading has not been checked by anyone else. Treat it as a question for the authors of #1760 and #1761 (merged as 4e42a1d8e and c2aaf907f).

Where

crates/victory-gpu/src/host.rs at 829188e96:

  • Batch::refresh_front (about line 12434): sift_front runs when VICTORY_FRONT_SIFT=1, with more than 256 spans and no shadow batch.
  • Batch::flush_all (about line 12662): sift_refreshes runs when VICTORY_FLUSH_SIFT=1 and there are more than 256 refreshes.

Both switches are still off by default.

The sequence

  1. The sift calls Shadow::nothing_new on every span, on all threads, before crate::watch::ask_ahead. A span that looks clean is removed.
  2. In refresh_front every span was already put in self.ahead before the sift, so Batch::add skips any later refresh of that range in the same submission. The removed span is not looked at again.
  3. A write to an owned range is noted with crate::watch::owner_wrote after its bytes are in. Its comment says a copy that began earlier "finds the pages written since". If the note is published after step 1 but before the copy would have run, nothing finds it.
  4. Without the sift, the workers call nothing_new after ask_ahead, next to the copy. They see the newer note and copy. With the sift, the GPU reads the older shadow bytes for this submission.

Main's default front path

Since acc6df7d4 (PR #1133), refresh_front also drops clean spans before ask_ahead when VICTORY_FRONT_SIFT is off, on one thread instead of all. So at 829188e96 the front sift does not change when a span is checked. If the sequence above is real, the default front path has it too. Only VICTORY_FLUSH_SIFT moves the check earlier than the default path does (more than 256 refreshes).

Suggested fix

  • Keep the spans the sift drops. Read the journal's asking number before the sift. After ask_ahead, if it has moved, run nothing_new again on the dropped spans whose pages were noted since, and put back any that now have something to copy. This costs nothing when no write came in meanwhile.
  • Or keep the old order above 256: sift after ask_ahead, in the workers, as flush_all does without the switch.
  • Add a test: hold owner_wrote behind a barrier between the sift and the copy, then check the shadow bytes. The existing sift tests use fixed stamps, so they pass with this gap.

Limits

This is a race window between threads, found by reading. Whether the title writes owned memory in that window in play is not known. The more-than-256 case comes up at heap-sized flushes, about once a frame.

Hardware where this was read against: RTX 3070 8 GB, Ryzen 7 5800X3D, 32 GB, Windows 11 26200, driver 621.24 (no run was made for this report).

**@⁠CuteBooty** on GitHub · 2026-11-29 20:57 UTC · [original](https://github.com/trustno1-coder/VIctory-NVIDIA/issues/3240) Not seen in play. No build or test was run for this. It was found by reading the source at main `829188e96`, and the reading has not been checked by anyone else. Treat it as a question for the authors of #1760 and #1761 (merged as `4e42a1d8e` and `c2aaf907f`). ## Where `crates/victory-gpu/src/host.rs` at `829188e96`: - `Batch::refresh_front` (about line 12434): `sift_front` runs when `VICTORY_FRONT_SIFT=1`, with more than 256 spans and no shadow batch. - `Batch::flush_all` (about line 12662): `sift_refreshes` runs when `VICTORY_FLUSH_SIFT=1` and there are more than 256 refreshes. Both switches are still off by default. ## The sequence 1. The sift calls `Shadow::nothing_new` on every span, on all threads, before `crate::watch::ask_ahead`. A span that looks clean is removed. 2. In `refresh_front` every span was already put in `self.ahead` before the sift, so `Batch::add` skips any later refresh of that range in the same submission. The removed span is not looked at again. 3. A write to an owned range is noted with `crate::watch::owner_wrote` after its bytes are in. Its comment says a copy that began earlier "finds the pages written since". If the note is published after step 1 but before the copy would have run, nothing finds it. 4. Without the sift, the workers call `nothing_new` after `ask_ahead`, next to the copy. They see the newer note and copy. With the sift, the GPU reads the older shadow bytes for this submission. ## Main's default front path Since `acc6df7d4` (PR #1133), `refresh_front` also drops clean spans before `ask_ahead` when `VICTORY_FRONT_SIFT` is off, on one thread instead of all. So at `829188e96` the front sift does not change when a span is checked. If the sequence above is real, the default front path has it too. Only `VICTORY_FLUSH_SIFT` moves the check earlier than the default path does (more than 256 refreshes). ## Suggested fix - Keep the spans the sift drops. Read the journal's asking number before the sift. After `ask_ahead`, if it has moved, run `nothing_new` again on the dropped spans whose pages were noted since, and put back any that now have something to copy. This costs nothing when no write came in meanwhile. - Or keep the old order above 256: sift after `ask_ahead`, in the workers, as `flush_all` does without the switch. - Add a test: hold `owner_wrote` behind a barrier between the sift and the copy, then check the shadow bytes. The existing sift tests use fixed stamps, so they pass with this gap. ## Limits This is a race window between threads, found by reading. Whether the title writes owned memory in that window in play is not known. The more-than-256 case comes up at heap-sized flushes, about once a frame. Hardware where this was read against: RTX 3070 8 GB, Ryzen 7 5800X3D, 32 GB, Windows 11 26200, driver 621.24 (no run was made for this report).
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-29 20:57:29 +00:00
Author
Owner

@⁠github-actions[bot] on GitHub · 2026-11-29 20:57 UTC · original

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.

  1. The play log, in %LOCALAPPDATA%\victory\logs\: the newest victory-nvidia-play-<date>-<time>-<number>.log (from victory.exe) or victory-nvidia-<date>-<time>.log (from the script launcher). The window shows its path at the start, on the line Log: ....
  2. The crash log: %LOCALAPPDATA%\VIctory\data\7952987A\crashes.log, and, if there is one from that run, the newest victory-<date>-<time>-<number>.crash.log in %LOCALAPPDATA%\VIctory\data\7952987A\temp\.

Also say which GPU, Windows version (10 or 11)

**@⁠github-actions[bot]** on GitHub · 2026-11-29 20:57 UTC · [original](https://github.com/trustno1-coder/VIctory-NVIDIA/issues/3240#issuecomment-7262490027) 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. 1. The play log, in `%LOCALAPPDATA%\victory\logs\`: the newest `victory-nvidia-play-<date>-<time>-<number>.log` (from `victory.exe`) or `victory-nvidia-<date>-<time>.log` (from the script launcher). The window shows its path at the start, on the line `Log: ...`. 2. The crash log: `%LOCALAPPDATA%\VIctory\data\7952987A\crashes.log`, and, if there is one from that run, the newest `victory-<date>-<time>-<number>.crash.log` in `%LOCALAPPDATA%\VIctory\data\7952987A\temp\`. Also say which GPU, Windows version (10 or 11)
This discussion has been locked. Commenting is limited to contributors.
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
github/trustno1-coder--VIctory-NVIDIA#3240
No description provided.