Tests: every GPU test module takes the shared lock, which diff_tests did not #1892

Open
github-bot wants to merge 2 commits from github-bot/gh-1892 into main AGit
Owner

@⁠fiestorra on GitHub · 2026-11-25 00:14 UTC · original
fiestorra:test/serialise-memory-tests → main · +27 −2 · 3 files · 2 commits · open

Cause found: diff_tests was the only GPU test module that made a Host without taking the shared lock

The crate already has the lock, for exactly this: emit::valu_tests::ONE_AT_A_TIME, whose comment says WARP can end the test process with an access violation and "other GPU test modules take this lock too". I audited all nine modules that make a Host:

module makes a host takes the lock
bvh_tests yes yes
diff_tests yes (3 tests) no
flow_tests yes yes
memory_tests yes yes
semantics_tests yes yes
stride_tests yes yes
synthetic_tests yes yes
valu_tests yes yes
waterfall_tests yes yes

diff_tests' three host-making tests — translated_shaders_draw_as_pc_ones, translated_mesh_shaders_draw_as_pc_ones, float_semantics_are_the_consoles — were dispatching beside whatever else the test threads were running, which is the shape of the failure you saw: memory_tests' title-memory test reading back thousands of pages set instead of the three it wrote, and passing when run alone.

The fix is that those three take the lock too, through one helper, and the lock's own comment now states the rule that nothing wrote down: a GPU test module that makes a Host without taking it is how the failure comes back.

What I can and cannot claim:

  • I cannot reproduce your failure here — three GPU suites skip on this machine (no dxc/console compiler for diff_tests, no SM 6.6 device for parts of it), so on my runs the unlocking tests never dispatched and the race never happened. cargo test --workspace --locked was green in two consecutive runs before and after.
  • What I can show is the audit: nine modules, one missing the lock, and it is the one with three dispatches. That is a mechanism, not a coincidence, and it matches your own reading of the failure.
  • If it still happens with this in place, the next suspect is not another module but the per-dispatch readback path in emit/host.rs, and the way to catch it would be to have the test keep the readback buffer it made rather than a fresh one.

Verification: cargo test -p victory-shader --locked --lib (209 passed, 2 ignored); cargo test --workspace --locked twice, 23 suites ok, with only the pre-existing victory-hle::modules::display::tests::sdr_and_display_deferrals failing in this headless session (it is what #1630 fixes); clippy --workspace --all-targets with and without --all-features clean under -D warnings; rustfmt --check clean on the two files touched.

Pull request: #1883

No game data is involved: test names and counts only.

Written with an AI assistant.

**@⁠fiestorra** on GitHub · 2026-11-25 00:14 UTC · [original](https://github.com/Marvisak/VIctory/pull/1892) `fiestorra:test/serialise-memory-tests` → `main` · +27 −2 · 3 files · 2 commits · open **Cause found: `diff_tests` was the only GPU test module that made a `Host` without taking the shared lock** The crate already has the lock, for exactly this: `emit::valu_tests::ONE_AT_A_TIME`, whose comment says WARP can end the test process with an access violation and "other GPU test modules take this lock too". I audited all nine modules that make a `Host`: | module | makes a host | takes the lock | |---|---|---| | `bvh_tests` | yes | yes | | **`diff_tests`** | **yes (3 tests)** | **no** | | `flow_tests` | yes | yes | | `memory_tests` | yes | yes | | `semantics_tests` | yes | yes | | `stride_tests` | yes | yes | | `synthetic_tests` | yes | yes | | `valu_tests` | yes | yes | | `waterfall_tests` | yes | yes | `diff_tests`' three host-making tests — `translated_shaders_draw_as_pc_ones`, `translated_mesh_shaders_draw_as_pc_ones`, `float_semantics_are_the_consoles` — were dispatching beside whatever else the test threads were running, which is the shape of the failure you saw: `memory_tests`' title-memory test reading back thousands of pages set instead of the three it wrote, and passing when run alone. The fix is that those three take the lock too, through one helper, and the lock's own comment now states the rule that nothing wrote down: **a GPU test module that makes a `Host` without taking it is how the failure comes back**. What I can and cannot claim: - **I cannot reproduce your failure here** — three GPU suites skip on this machine (no `dxc`/console compiler for `diff_tests`, no SM 6.6 device for parts of it), so on my runs the unlocking tests never dispatched and the race never happened. `cargo test --workspace --locked` was green in two consecutive runs before and after. - **What I can show is the audit**: nine modules, one missing the lock, and it is the one with three dispatches. That is a mechanism, not a coincidence, and it matches your own reading of the failure. - If it still happens with this in place, the next suspect is not another module but the per-dispatch readback path in `emit/host.rs`, and the way to catch it would be to have the test keep the readback buffer it made rather than a fresh one. Verification: `cargo test -p victory-shader --locked --lib` (209 passed, 2 ignored); `cargo test --workspace --locked` twice, 23 suites ok, with only the pre-existing `victory-hle::modules::display::tests::sdr_and_display_deferrals` failing in this headless session (it is what #1630 fixes); `clippy --workspace --all-targets` with and without `--all-features` clean under `-D warnings`; `rustfmt --check` clean on the two files touched. Pull request: #1883 No game data is involved: test names and counts only. Written with an AI assistant.
The lock exists because WARP can end the test process with an access
violation, and because two tests dispatching at once can have one read back
what the other wrote: that is the shape of #1882, where
memory_tests::title_memory_is_read_and_written_at_computed_addresses failed
now and then in a full workspace run and reported thousands of pages set
instead of three, while passing when run alone.

diff_tests was the only module that makes a Host without taking it: three
tests there (translated_shaders_draw_as_pc_ones,
translated_mesh_shaders_draw_as_pc_ones, float_semantics_are_the_consoles)
dispatched beside whatever else the test threads were running. They take it
now, through one helper, and the lock's own documentation says the rule the
audit found written nowhere: a module that makes a Host without it is how
the failure comes back.

Audited all nine GPU test modules of the crate: each makes its Host under
the lock.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 04:47:48 +00:00
Author
Owner

@⁠Headache3318 on GitHub · 2026-11-25 01:43 UTC · original

Tested on Linux (Arch, kernel 7.3.5, 3× RTX 4090 driver 620.73.04), Rust 1.98.1 (pinned). PR head 94605b3 applied cleanly onto current main ccfb029.

  • cargo test -p victory-shader --locked: 144 passed, 0 failed, 2 ignored. All tests pass.
  • cargo clippy -p victory-shader --all-targets -- -D warnings: 4 pre-existing errors in test code (fail identically on main ccfb029). The PR introduces no new clippy warnings.

Not tested: Windows MSVC build, the title itself. AI-assisted.

**@⁠Headache3318** on GitHub · 2026-11-25 01:43 UTC · [original](https://github.com/Marvisak/VIctory/pull/1892#issuecomment-7149885153) Tested on Linux (Arch, kernel 7.3.5, 3× RTX 4090 driver 620.73.04), Rust 1.98.1 (pinned). PR head `94605b3` applied cleanly onto current `main` `ccfb029`. - `cargo test -p victory-shader --locked`: 144 passed, 0 failed, 2 ignored. All tests pass. - `cargo clippy -p victory-shader --all-targets -- -D warnings`: 4 pre-existing errors in test code (fail identically on main `ccfb029`). The PR introduces no new clippy warnings. Not tested: Windows MSVC build, the title itself. AI-assisted.
Author
Owner

@⁠Marvisak on GitHub · 2026-11-25 08:20 UTC · original

Automated triage for the maintainers.

Needs work.

Making the host-creating tests in diff_tests take valu_tests::ONE_AT_A_TIME is right and harmless. The audit is incomplete, though, so the new doc comment ("Every GPU test module takes this lock ... diff_tests was the last module missing it") is not true after this PR. On main, these tests also make a Host without the lock:

  • diff_tests::cube_gradients_pick_the_level, which runs on both the hardware device and WARP (Host::new(warp)).
  • diff_tests::translated_compute_matches_pc.
  • The GPU test in crates/victory-shader/src/emit/rect.rs (Host::new(warp) for hardware and WARP).

What it needs:

  • Take the lock in those three as well.
  • Word the comment as the rule itself, without claiming it is already met everywhere.
  • Present the link to #1882 as a likely cause, not a found one. You say you could not reproduce the failure, and two tests sharing a process but using separate Hosts and readback buffers reading each other's results is not shown.

CI: check passing.


Generated by Claude Code

**@⁠Marvisak** on GitHub · 2026-11-25 08:20 UTC · [original](https://github.com/Marvisak/VIctory/pull/1892#issuecomment-7156906205) <!-- victory-triage v1 head=94605b3649a1a1746fac713ae77b2d9ef5fd47da verdict=needs-work at=2026-11-25T08:20:21Z --> Automated triage for the maintainers. **Needs work.** Making the host-creating tests in `diff_tests` take `valu_tests::ONE_AT_A_TIME` is right and harmless. The audit is incomplete, though, so the new doc comment ("**Every GPU test module takes this lock** ... `diff_tests` was the last module missing it") is not true after this PR. On main, these tests also make a `Host` without the lock: - `diff_tests::cube_gradients_pick_the_level`, which runs on both the hardware device and WARP (`Host::new(warp)`). - `diff_tests::translated_compute_matches_pc`. - The GPU test in `crates/victory-shader/src/emit/rect.rs` (`Host::new(warp)` for hardware and WARP). What it needs: - Take the lock in those three as well. - Word the comment as the rule itself, without claiming it is already met everywhere. - Present the link to #1882 as a likely cause, not a found one. You say you could not reproduce the failure, and two tests sharing a process but using separate `Host`s and readback buffers reading each other's results is not shown. CI: `check` passing. --- _Generated by [Claude Code](https://claude.ai/code)_
Author
Owner

@⁠sinan-cmyk on GitHub · 2026-11-25 11:43 UTC · original

Offline measurement on a retail dump

Result: no count change against main.

I merged head 94605b36 onto main 940d32f (clean merge) and ran victory translate --validate --list on shaders.rpf (1.0.2.1), with dxil.dll 1.8.2502.11. I compared the result with main program by program (25,889 programs). Validated: 23,918 on main, 23,918 with this PR.

No program changes its failure reason. The count shows that the change rejects nothing on this data. It does not show whether the output is right.

No shader names or data are included, per the asset policy. AI-assisted (Claude Code).

**@⁠sinan-cmyk** on GitHub · 2026-11-25 11:43 UTC · [original](https://github.com/Marvisak/VIctory/pull/1892#issuecomment-7161413431) ### Offline measurement on a retail dump **Result: no count change against `main`.** I merged head 94605b36 onto `main` 940d32f (clean merge) and ran `victory translate --validate --list` on `shaders.rpf` (1.0.2.1), with dxil.dll 1.8.2502.11. I compared the result with `main` program by program (25,889 programs). Validated: 23,918 on `main`, 23,918 with this PR. No program changes its failure reason. The count shows that the change rejects nothing on this data. It does not show whether the output is right. No shader names or data are included, per the asset policy. AI-assisted (Claude Code).
github-bot force-pushed github-bot/gh-1892 from 94605b3649 to 6e127213e3 2026-11-26 12:13:49 +00:00 Compare
Author
Owner

@⁠catminou4 on GitHub · 2026-11-25 02:17 UTC · original · reviewed

Static review only: GPU test harness is Windows-only — nothing runs on macOS; source review of the diff.

Shared lock across every GPU test module (fixing the diff_tests deadlock class) — right direction for the parallel Windows suite.

**@⁠catminou4** on GitHub · 2026-11-25 02:17 UTC · [original](https://github.com/Marvisak/VIctory/pull/1892#pullrequestreview-6050698998) · **reviewed** Static review only: GPU test harness is Windows-only — nothing runs on macOS; source review of the diff. Shared lock across every GPU test module (fixing the diff_tests deadlock class) — right direction for the parallel Windows suite.
Author
Owner

@⁠mercuryVM on GitHub · 2026-11-25 02:58 UTC · original · reviewed

Read only, not built: the branch sits on a newer upstream main than our fork's last sync, so a merge pulls in dozens of upstream files, and I couldn't test it in isolation here.

From reading, the change is right. diff_tests was the one module making a Host without ONE_AT_A_TIME, and taking the lock in its three tests matches what the other GPU test modules do. Moving the lock's doc comment to the shared helper is fine.

AI-assisted (Claude Code).

**@⁠mercuryVM** on GitHub · 2026-11-25 02:58 UTC · [original](https://github.com/Marvisak/VIctory/pull/1892#pullrequestreview-6051200654) · **reviewed** Read only, not built: the branch sits on a newer upstream main than our fork's last sync, so a merge pulls in dozens of upstream files, and I couldn't test it in isolation here. From reading, the change is right. `diff_tests` was the one module making a `Host` without `ONE_AT_A_TIME`, and taking the lock in its three tests matches what the other GPU test modules do. Moving the lock's doc comment to the shared helper is fine. AI-assisted (Claude Code).
Author
Owner

@⁠fiestorra on GitHub · 2026-11-26 12:13 UTC · original

All four points taken

The audit is now complete, and the comment says the rule instead of claiming it was already met.

  • The three missing tests take the lock: diff_tests::cube_gradients_pick_the_level and diff_tests::translated_compute_matches_pc (through the same one_at_a_time() helper as their neighbours), and rect.rs::rectangles_get_their_fourth_corner, which makes a Host for hardware and WARP per corner order (super::super::valu_tests::ONE_AT_A_TIME).
  • The wording: the doc comment no longer says "every GPU test module takes this lock" as a fact already true. It states the rule — a GPU test that makes a Host takes it — and says diff_tests and rect.rs were the modules that did not.
  • #1882 is a likely cause, not a found one: the comment now says "the likeliest cause … (not reproduced on its own)". I could not reproduce that failure either, and two tests with their own Host and their own readback buffers should not read each other's memory; what the lock does is remove the one way they could, and stop the WARP hangs, which are reproducible.

What this does not do: prove that a dispatch and a readback from separate hosts can collide — I have not shown that, only that the lock costs a test at a time and makes the suite deterministic. If the failure comes back with every module holding the lock, the cause is elsewhere and this PR is not the fix.

Written with an AI assistant.

**@⁠fiestorra** on GitHub · 2026-11-26 12:13 UTC · [original](https://github.com/Marvisak/VIctory/pull/1892#issuecomment-7191721706) **All four points taken** The audit is now complete, and the comment says the rule instead of claiming it was already met. - **The three missing tests take the lock**: `diff_tests::cube_gradients_pick_the_level` and `diff_tests::translated_compute_matches_pc` (through the same `one_at_a_time()` helper as their neighbours), and `rect.rs::rectangles_get_their_fourth_corner`, which makes a `Host` for hardware and WARP per corner order (`super::super::valu_tests::ONE_AT_A_TIME`). - **The wording**: the doc comment no longer says "*every* GPU test module takes this lock" as a fact already true. It states the rule — a GPU test that makes a `Host` takes it — and says `diff_tests` and `rect.rs` were the modules that did not. - **#1882 is a likely cause, not a found one**: the comment now says "the likeliest cause … (not reproduced on its own)". I could not reproduce that failure either, and two tests with their own `Host` and their own readback buffers should not read each other's memory; what the lock does is remove the one way they could, and stop the WARP hangs, which are reproducible. What this does not do: prove that a dispatch and a readback from separate hosts can collide — I have not shown that, only that the lock costs a test at a time and makes the suite deterministic. If the failure comes back with every module holding the lock, the cause is elsewhere and this PR is not the fix. Written with an AI assistant.
This pull request can be merged automatically.
You are not authorized to merge this pull request.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin '+refs/pull/1892/head:github-bot/gh-1892'
git switch 'github-bot/gh-1892'

Merge

Merge the changes and update on Forgejo.
git switch 'main'
git merge --no-ff 'github-bot/gh-1892'
git switch 'github-bot/gh-1892'
git rebase 'main'
git switch 'main'
git merge --ff-only 'github-bot/gh-1892'
git switch 'github-bot/gh-1892'
git rebase 'main'
git switch 'main'
git merge --no-ff 'github-bot/gh-1892'
git switch 'main'
git merge --squash 'github-bot/gh-1892'
git switch 'main'
git merge --ff-only 'github-bot/gh-1892'
git switch 'main'
git merge 'github-bot/gh-1892'
git push origin 'main'
This discussion has been locked. Commenting is limited to contributors.
No reviewers
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/Marvisak--VIctory!1892
No description provided.