Indirect args may be read early: 281k clamped-after-write hits a window, unverified #124

Closed
opened 2026-12-01 16:38:22 +00:00 by github-bot · 3 comments
Owner

@⁠TheRifai on GitHub · 2026-12-01 16:37 UTC · original

Finding (rules 12, 14, 29)

greenfield/vkback/src/lib.rs:3609 counts ExecuteIndirect clamped in its epoch's prologue after shader writes in that epoch (args may be read early) whenever a draw/dispatch wrote in the epoch before a later indirect op whose arguments the epoch prologue already clamped. The code calls it an upper bound — the writes may be to unrelated memory — but no task or issue owns the counter, and the volume is very high.

Seen on: main cab86d1, house save, scripted camera walk (VICTORY_KEYS W/I/K/J/L/O/P/Enter), 180 s, GE-Proton11-16 / RX 9070 XT. Run: /tmp/opencode/capture/explore/walk/runs/20261201-173035. vk.log stats lines: +281,018 in one window (cumulative 453,758), with 9 distinct sampled pipelines (top 0x1c1d5430, kind Dispatch). The Series X console run shows the same kind; no validation error or rule-32 line accompanies it.

The risk is concrete: if one of those shader writes really targets the indirect argument bytes, the clamp saw older values and the dispatch could use stale counts/offsets — a silent wrong draw, exactly the class of bug rule 32 is for. VKB_CLAMP_VERIFY=1 already exists (sync.rs::verify_clamp) to compare the record against a check run right before the op.

Next

Run the house scene once with VKB_CLAMP_VERIFY=1 and count real differences (clampreport.rs) against the 281k upper bound. If none, turn the counter into a note with the reason and a TASKS row; if some, name the pipeline and find which shader writes the argument bytes. Evidence: verified difference count + the pipeline's shader family from gpuprof/names.py, not a picture alone.

**@⁠TheRifai** on GitHub · 2026-12-01 16:37 UTC · [original](https://github.com/vktory6/VKtory/issues/124) ## Finding (rules 12, 14, 29) `greenfield/vkback/src/lib.rs:3609` counts `ExecuteIndirect clamped in its epoch's prologue after shader writes in that epoch (args may be read early)` whenever a draw/dispatch wrote in the epoch before a later indirect op whose arguments the epoch prologue already clamped. The code calls it an **upper bound** — the writes may be to unrelated memory — but no task or issue owns the counter, and the volume is very high. Seen on: main `cab86d1`, house save, scripted camera walk (`VICTORY_KEYS` W/I/K/J/L/O/P/Enter), 180 s, GE-Proton11-16 / RX 9070 XT. Run: `/tmp/opencode/capture/explore/walk/runs/20261201-173035`. `vk.log` stats lines: **+281,018** in one window (cumulative 453,758), with 9 distinct sampled pipelines (top `0x1c1d5430`, kind Dispatch). The Series X console run shows the same kind; no validation error or rule-32 line accompanies it. The risk is concrete: if one of those shader writes really targets the indirect argument bytes, the clamp saw older values and the dispatch could use stale counts/offsets — a silent wrong draw, exactly the class of bug rule 32 is for. `VKB_CLAMP_VERIFY=1` already exists (`sync.rs::verify_clamp`) to compare the record against a check run right before the op. ## Next Run the house scene once with `VKB_CLAMP_VERIFY=1` and count real differences (clampreport.rs) against the 281k upper bound. If none, turn the counter into a note with the reason and a TASKS row; if some, name the pipeline and find which shader writes the argument bytes. Evidence: verified difference count + the pipeline's shader family from `gpuprof/names.py`, not a picture alone.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-12-01 16:38:22 +00:00
Author
Owner

@⁠TheRifai on GitHub · 2026-12-01 16:42 UTC · original

Verified with the same camera walk and VKB_CLAMP_VERIFY=1 (main cab86d1, GE-Proton11-16): the sync line reports 11,835,169 indirect clamps and 2,442,363 checked in line, and GPU clamp reports produced zero differences (no 'clamp report' line, no rule-32 in loud.txt). So the 281k/window upper bound did not translate into a wrong argument in this run. The counter is still unowned in TASKS and the check only covers one scene; leaving this open for a second scene or a different title, with the no-difference measurement as evidence. Run: /tmp/opencode/capture/verify-clamp2/runs/20261201-173946.

**@⁠TheRifai** on GitHub · 2026-12-01 16:42 UTC · [original](https://github.com/vktory6/VKtory/issues/124#issuecomment-7318069295) Verified with the same camera walk and VKB_CLAMP_VERIFY=1 (main cab86d1, GE-Proton11-16): the sync line reports 11,835,169 indirect clamps and 2,442,363 checked in line, and GPU clamp reports produced zero differences (no 'clamp report' line, no rule-32 in loud.txt). So the 281k/window upper bound did not translate into a wrong argument in this run. The counter is still unowned in TASKS and the check only covers one scene; leaving this open for a second scene or a different title, with the no-difference measurement as evidence. Run: /tmp/opencode/capture/verify-clamp2/runs/20261201-173946.
Author
Owner

@⁠vktory6 on GitHub · 2026-12-01 16:44 UTC · original

Good catch that nobody had answered this in the house scene. It was checked in the prison: with VKB_CLAMP_VERIFY=1, a 60 s prison run checked 102,170 at-risk dispatches in line, and 0 had changed arguments (docs/learnings/upstream-review-1129.md, "gpu-hints counts"). That's why the counter is an upper-bound note, not a loud error.

The house walk hasn't been verified, though, and your numbers are higher there. Your proposed next step is exactly right: one house run with VKB_CLAMP_VERIFY=1, then grep 'arguments changed' vk.log and the sync line's checked in line count. If it's 0 again, post the counts here and I'll add them to the learning and close this. If there are any, the pipeline names are the lead. Leaving it open for that run.

**@⁠vktory6** on GitHub · 2026-12-01 16:44 UTC · [original](https://github.com/vktory6/VKtory/issues/124#issuecomment-7318141693) Good catch that nobody had answered this in the house scene. It was checked in the prison: with `VKB_CLAMP_VERIFY=1`, a 60 s prison run checked 102,170 at-risk dispatches in line, and 0 had changed arguments (`docs/learnings/upstream-review-1129.md`, "gpu-hints counts"). That's why the counter is an upper-bound note, not a loud error. The house walk hasn't been verified, though, and your numbers are higher there. Your proposed next step is exactly right: one house run with `VKB_CLAMP_VERIFY=1`, then `grep 'arguments changed' vk.log` and the sync line's `checked in line` count. If it's 0 again, post the counts here and I'll add them to the learning and close this. If there are any, the pipeline names are the lead. Leaving it open for that run.
Author
Owner

@⁠vktory6 on GitHub · 2026-12-01 16:50 UTC · original

Thanks for running it. 2,442,363 dispatches checked in line, 0 changed, on top of the prison's 102,170 with 0 changed. That's two scenes, verified in line, with no difference, which is the evidence this counter needed. It's an upper-bound note by construction (any shader write in the epoch counts), and it doesn't stand for a known deviation, so I added your numbers to the learning that explains it (github.com/vktory6/VKtory@491cd34) and I'm closing this. If a VKB_CLAMP_VERIFY=1 run ever shows an arguments changed line, that's a loud error with the pipeline named; please open an issue then.

**@⁠vktory6** on GitHub · 2026-12-01 16:50 UTC · [original](https://github.com/vktory6/VKtory/issues/124#issuecomment-7318311371) Thanks for running it. 2,442,363 dispatches checked in line, 0 changed, on top of the prison's 102,170 with 0 changed. That's two scenes, verified in line, with no difference, which is the evidence this counter needed. It's an upper-bound note by construction (any shader write in the epoch counts), and it doesn't stand for a known deviation, so I added your numbers to the learning that explains it (https://github.com/vktory6/VKtory/commit/491cd34) and I'm closing this. If a `VKB_CLAMP_VERIFY=1` run ever shows an `arguments changed` line, that's a loud error with the pipeline named; please open an issue then.
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/vktory6--VKtory#124
No description provided.