GPU tests: a batch's hold on a copy ends before its pool is freed #1911

Closed
Mericas77 wants to merge 1 commit from upstream-pr/1913 into main
Mericas77 commented 2026-11-25 00:46:08 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by Mericas77 on 2026-11-25T00:46:08Z.


Summary

On an RTX 4070, cargo test -p victory-gpu --lib in its default parallel mode fails intermittently in watch::tests: writes_mark_every_tracker_of_their_page, writes_through_another_mapping_mark_the_tracker and kernel_reads_into_guarded_blocks_after_opening. They never fail with --test-threads=1.

One cause is in host.rs's a_copy_is_refreshed_once_per_submission_by_the_pages_written. It keeps both of its Batch values until the end of the test: the first one is shadowed, not dropped. A Batch holds an Arc<Shadow> (in refreshes and current), so the copy watching the test's pool outlives crate::watch::tests::free(p). A watch test running in parallel can then take the same addresses.

With this change, the second batch replaces the first and is dropped before the pool is freed. It changes tests only; the runtime is unchanged.

Testing (RTX 4070, driver 621.01, Windows 11 26300)

cargo test -p victory-gpu --lib --locked, 20 parallel runs each:

runs with a watch::tests failure
70564ae 11 / 20
70564ae + this PR 0 / 20
#1779 0 / 20 (1 / 10 in an earlier series)
#1779 + this PR 0 / 20

cargo clippy -p victory-gpu --all-targets --locked -- -D warnings is clean.

At 70564ae there is a second source: on NVIDIA, memory::tests::lists_share_a_table_and_copies_keep_their_views panics early because of the 1,000,000 view heap cap, and leaves watched memory behind. #1779 fixes that, which is why the flake is rarer on top of it. This change fixes the separate leak in the batch test.

AI-assisted (Gemini found it; Claude Code verified it and wrote it up).

<!-- greyfinch-sync:Marvisak/VIctory:issue:6594504588 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/1913). Originally posted by [Mericas77](https://github.com/Mericas77) on 2026-11-25T00:46:08Z. --- <!-- claude-projects-attribution --> ## Summary On an RTX 4070, `cargo test -p victory-gpu --lib` in its default parallel mode fails intermittently in `watch::tests`: `writes_mark_every_tracker_of_their_page`, `writes_through_another_mapping_mark_the_tracker` and `kernel_reads_into_guarded_blocks_after_opening`. They never fail with `--test-threads=1`. One cause is in `host.rs`'s `a_copy_is_refreshed_once_per_submission_by_the_pages_written`. It keeps both of its `Batch` values until the end of the test: the first one is shadowed, not dropped. A `Batch` holds an `Arc<Shadow>` (in `refreshes` and `current`), so the copy watching the test's pool outlives `crate::watch::tests::free(p)`. A watch test running in parallel can then take the same addresses. With this change, the second batch replaces the first and is dropped before the pool is freed. It changes tests only; the runtime is unchanged. ## Testing (RTX 4070, driver 621.01, Windows 11 26300) `cargo test -p victory-gpu --lib --locked`, 20 parallel runs each: | | runs with a `watch::tests` failure | |---|---| | `70564ae` | 11 / 20 | | `70564ae` + this PR | 0 / 20 | | #1779 | 0 / 20 (1 / 10 in an earlier series) | | #1779 + this PR | 0 / 20 | `cargo clippy -p victory-gpu --all-targets --locked -- -D warnings` is clean. At `70564ae` there is a second source: on NVIDIA, `memory::tests::lists_share_a_table_and_copies_keep_their_views` panics early because of the 1,000,000 view heap cap, and leaves watched memory behind. #1779 fixes that, which is why the flake is rarer on top of it. This change fixes the separate leak in the batch test. AI-assisted (Gemini found it; Claude Code verified it and wrote it up).
catminou4 commented 2026-11-25 03:02:44 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by catminou4 on 2026-11-25T02:10:18Z.

Review: COMMENTED


Static review only: victory-gpu is Windows-only (D3D12/windows_sys) — nothing compiles or runs on macOS; source review of the diff.

GPU test: a batch's hold on a copy ends…: test-only GPU coverage for copy lifetime — good.

<!-- greyfinch-sync:Marvisak/VIctory:review:6050610892 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/1913#pullrequestreview-6050610892). Originally posted by [catminou4](https://github.com/catminou4) on 2026-11-25T02:10:18Z. **Review:** COMMENTED --- Static review only: victory-gpu is Windows-only (D3D12/windows_sys) — nothing compiles or runs on macOS; source review of the diff. GPU test: a batch's hold on a copy ends…: test-only GPU coverage for copy lifetime — good.
mercuryVM commented 2026-11-25 06:02:04 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by mercuryVM on 2026-11-25T05:41:12Z.

Review: APPROVED


Tested 27ccf62 on Windows 11, RTX 5070, MSVC: builds, clippy -D warnings clean with and without --all-features, cargo test --workspace --no-fail-fast 730 passed on our fork main; the 9 failures are the ones that fail on that main without this PR (host validator and environment).

  • The diagnosis is right. The first Batch was shadowed, not dropped, so its Arc<Shadow> kept the copy, and through it the watch on the test's pool, alive past watch::tests::free(p). A parallel watch test could then reuse those addresses.
  • Reassigning batch drops the first one at the assignment, and the explicit drop(batch) before drop(copy) and free(p) releases the last hold in the right order. Test only.

Merged into our fork's main.

AI-assisted (Claude Code).

<!-- greyfinch-sync:Marvisak/VIctory:review:6052415307 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/1913#pullrequestreview-6052415307). Originally posted by [mercuryVM](https://github.com/mercuryVM) on 2026-11-25T05:41:12Z. **Review:** APPROVED --- Tested 27ccf62 on Windows 11, RTX 5070, MSVC: builds, clippy `-D warnings` clean with and without `--all-features`, `cargo test --workspace --no-fail-fast` 730 passed on our fork main; the 9 failures are the ones that fail on that main without this PR (host validator and environment). - The diagnosis is right. The first `Batch` was shadowed, not dropped, so its `Arc<Shadow>` kept the copy, and through it the watch on the test's pool, alive past `watch::tests::free(p)`. A parallel watch test could then reuse those addresses. - Reassigning `batch` drops the first one at the assignment, and the explicit `drop(batch)` before `drop(copy)` and `free(p)` releases the last hold in the right order. Test only. Merged into our fork's main. AI-assisted (Claude Code).
Marvisak commented 2026-11-25 09:06:10 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by Marvisak on 2026-11-25T08:17:04Z.


Automated triage for the maintainers.

Merge candidate.

This is a test-only fix in crates/victory-gpu/src/host.rs, test a_copy_is_refreshed_once_per_submission_by_the_pages_written. On main, the second let mut batch shadows the first batch without dropping it. Both Batch values hold an Arc<Shadow> (in refreshes/current) until after crate::watch::tests::free(p). Shadow::drop (in shadow.rs) gives the watch marks back, so the pool is freed while still watched. The PR reuses the variable, which drops the first batch, and drops the second batch before copy and the pool. That matches the leak the PR describes, and the runtime is unchanged.

CI: check fails, but only in victory-shader's synthetic_tests (gathers_at_a_level_match_the_hardware, permutes_read_the_lane_named_and_zero_from_lanes_left_out). This PR doesn't touch that code, and other PRs show the same two failures.


Generated by Claude Code

<!-- greyfinch-sync:Marvisak/VIctory:comment:7156835946 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/1913#issuecomment-7156835946). Originally posted by [Marvisak](https://github.com/Marvisak) on 2026-11-25T08:17:04Z. --- <!-- victory-triage v1 head=27ccf626a4f50a69da0478e6923acef8a65ad142 verdict=merge-candidate at=2026-11-25T08:16:53Z --> Automated triage for the maintainers. **Merge candidate.** This is a test-only fix in `crates/victory-gpu/src/host.rs`, test `a_copy_is_refreshed_once_per_submission_by_the_pages_written`. On `main`, the second `let mut batch` shadows the first batch without dropping it. Both `Batch` values hold an `Arc<Shadow>` (in `refreshes`/`current`) until after `crate::watch::tests::free(p)`. `Shadow::drop` (in `shadow.rs`) gives the watch marks back, so the pool is freed while still watched. The PR reuses the variable, which drops the first batch, and drops the second batch before `copy` and the pool. That matches the leak the PR describes, and the runtime is unchanged. CI: `check` fails, but only in `victory-shader`'s `synthetic_tests` (`gathers_at_a_level_match_the_hardware`, `permutes_read_the_lane_named_and_zero_from_lanes_left_out`). This PR doesn't touch that code, and other PRs show the same two failures. --- _Generated by [Claude Code](https://claude.ai/code)_
upstream-sync closed this pull request 2026-11-25 21:02:08 +00:00

Pull request closed

Sign in to join this conversation.
No reviewers
No labels
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.

Reference
Marvisak/VIctory!1911
No description provided.