GPU tests: a freed test pool keeps its addresses, and mark tests hold off submissions #3085

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

@⁠0xkn0wh3r3 on GitHub · 2026-11-26 07:02 UTC · original
0xkn0wh3r3:tests/parallel-races → main · +25 −3 · 3 files · 2 commits · open

Run in parallel (the default cargo test), victory-gpu's shadow and watch tests fail now and then, and each passes when run alone. There are two causes, and both are fixed in the tests only.

1. A freed test pool's addresses were handed out again while a tracker still guarded them.
watch::protect counts a page that is already in the guard set as guarded, and skips VirtualProtect for it. A test can leave a tracker of its pool behind (a host copy or a texture's staging that something global still holds) and then free the pool. I instrumented watch::tests::free, and in every run some tests freed memory that was still in GUARDS:

  • host::batch::a_copy_is_refreshed_once_per_submission_by_the_pages_written
  • host::withholding::only_programs_using_title_memory_are_withheld
  • texture::tests::a_texture_viewed_from_a_later_level_is_staged_from_it_only

If another test's VirtualAlloc lands on those addresses, its pages count as guarded already. Its writes then never fault, so nothing is seen as changed or saved. This produced the failures in watch::tests::armed_ranges_keep_their_pages_bytes_from_before_the_first_write, unmapped_pages_are_taken_apart and the partial-refresh tests.

watch::tests::free now decommits the pool and keeps its addresses reserved, so no later allocation lands there, whichever test leaked the tracker.

2. A submission of a test running alongside took the marks a mark test had just set.
shadow::copy_back_marks takes every mark in the bitmaps, and Host::execute calls it. The fix adds host::tests::no_submissions(), which holds the submission lock while it is alive, as the read-mark tests in host.rs already do. These tests now hold it:

  • marked_pages_go_back_by_the_bytes_the_gpu_changed
  • marks_of_shaders_using_title_memory_are_held_back
  • partial_refresh_under_marked_range_updates_saved_bytes

None of them submits work itself.

Measured. 20 runs of cargo test -p victory-gpu --lib on Windows with an NVIDIA GPU.

  • On main: before the fix, 1 shadow failure in 20 runs; after it, no shadow or watch failure in 20 runs.
  • On a branch with more open GPU PRs merged in, where these races show up more often: before, 8 of 20 runs had a shadow or watch failure; after, none in 20 runs.

Two tests fail on main in every run, with or without this change: memory::tests::lists_share_a_table_and_copies_keep_their_views and descriptor::host::tests::dynamic_slots_are_held_until_released. They are not related to this change.

**@⁠0xkn0wh3r3** on GitHub · 2026-11-26 07:02 UTC · [original](https://github.com/Marvisak/VIctory/pull/3085) `0xkn0wh3r3:tests/parallel-races` → `main` · +25 −3 · 3 files · 2 commits · open Run in parallel (the default `cargo test`), victory-gpu's shadow and watch tests fail now and then, and each passes when run alone. There are two causes, and both are fixed in the tests only. **1. A freed test pool's addresses were handed out again while a tracker still guarded them.** `watch::protect` counts a page that is already in the guard set as guarded, and skips `VirtualProtect` for it. A test can leave a tracker of its pool behind (a host copy or a texture's staging that something global still holds) and then free the pool. I instrumented `watch::tests::free`, and in every run some tests freed memory that was still in `GUARDS`: - `host::batch::a_copy_is_refreshed_once_per_submission_by_the_pages_written` - `host::withholding::only_programs_using_title_memory_are_withheld` - `texture::tests::a_texture_viewed_from_a_later_level_is_staged_from_it_only` If another test's `VirtualAlloc` lands on those addresses, its pages count as guarded already. Its writes then never fault, so nothing is seen as changed or saved. This produced the failures in `watch::tests::armed_ranges_keep_their_pages_bytes_from_before_the_first_write`, `unmapped_pages_are_taken_apart` and the partial-refresh tests. `watch::tests::free` now decommits the pool and keeps its addresses reserved, so no later allocation lands there, whichever test leaked the tracker. **2. A submission of a test running alongside took the marks a mark test had just set.** `shadow::copy_back_marks` takes every mark in the bitmaps, and `Host::execute` calls it. The fix adds `host::tests::no_submissions()`, which holds the submission lock while it is alive, as the read-mark tests in `host.rs` already do. These tests now hold it: - `marked_pages_go_back_by_the_bytes_the_gpu_changed` - `marks_of_shaders_using_title_memory_are_held_back` - `partial_refresh_under_marked_range_updates_saved_bytes` None of them submits work itself. **Measured.** 20 runs of `cargo test -p victory-gpu --lib` on Windows with an NVIDIA GPU. - **On main:** before the fix, 1 shadow failure in 20 runs; after it, no shadow or watch failure in 20 runs. - **On a branch with more open GPU PRs merged in**, where these races show up more often: before, 8 of 20 runs had a shadow or watch failure; after, none in 20 runs. Two tests fail on main in every run, with or without this change: `memory::tests::lists_share_a_table_and_copies_keep_their_views` and `descriptor::host::tests::dynamic_slots_are_held_until_released`. They are not related to this change.
Run in parallel, victory-gpu's shadow and watch tests failed now and then
(about one run in three), each passing alone:

- A test can leave a tracker of its pool behind (a host copy or a
  texture's staging something global still holds) and then free the
  pool. Its pages stay in the guard set, and a pool another test got at
  the same addresses counts as guarded already: its writes never fault,
  so nothing is seen changed or saved (armed_ranges_keep_..., the
  partial-refresh tests). watch::tests::free now decommits the pool and
  keeps its addresses reserved, so no allocation lands there again.
- copy_back_marks takes every mark set in the bitmaps, and a test
  submitting alongside took the marks a mark test had just set
  (marked_pages_go_back_..., marks_of_shaders_using_title_memory_...).
  Those tests now hold the submission lock while they run, as the
  read-mark tests do (host::tests::no_submissions).
partial_refresh_under_marked_range_updates_saved_bytes failed now and then
in parallel: page 0 came back whole from the copy over the title's later
writes, or the copy's writes did not come back at all, as if a submission
of a test running alongside had worked through the copy first. It does no
submission of its own, so it holds the submission lock.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 07:27:01 +00:00
Author
Owner

@⁠Dukestar69 on GitHub · 2026-11-26 07:07 UTC · original · approved these changes

Tested locally merged onto origin/main (63bcca4) on Windows 11 x64 (NVIDIA GeForce RTX 5090):

  • cargo test -p victory-gpu watch::tests -- --test-threads=1: 15 passed, 0 failed.
  • cargo test -p victory-gpu shadow::tests -- --test-threads=1: 9 passed, 0 failed.
  • cargo clippy -p victory-gpu --all-targets -- -D warnings: clean.
  • cargo xtask policy: 191 files ok.

Synthetic tests only (no game files used). AI-assisted (Gemini 4 Neon).

**@⁠Dukestar69** on GitHub · 2026-11-26 07:07 UTC · [original](https://github.com/Marvisak/VIctory/pull/3085#pullrequestreview-6069846269) · **approved these changes** Tested locally merged onto `origin/main` (`63bcca4`) on Windows 11 x64 (NVIDIA GeForce RTX 5090): - `cargo test -p victory-gpu watch::tests -- --test-threads=1`: 15 passed, 0 failed. - `cargo test -p victory-gpu shadow::tests -- --test-threads=1`: 9 passed, 0 failed. - `cargo clippy -p victory-gpu --all-targets -- -D warnings`: clean. - `cargo xtask policy`: 191 files ok. Synthetic tests only (no game files used). AI-assisted (Gemini 4 Neon).
Author
Owner

@⁠oni-swr on GitHub · 2026-11-26 07:38 UTC · original

Independent WARP-only verification of this PR at b57d5a0cc544c4dc5bb4764bded9f8eb1b271eb8 (claim: #1633). Existing tests only, no source edits, no PR. AI use: Claude Code (Claude Sonnet 5.5), coordinated by Codex (gpt-6.2-sol).

Result. I did not reproduce the shadow/watch/mark flake on the parent under WARP, so these runs neither confirm nor refute the PR's fix. The PR head had no failures in 180 runs.

Compared

  • base 63bcca43c6a00a758510398fa43096ce7e4f7df0 (the PR's base)
  • 46b8c8163580e6717c80cd0938811e16b716e7a0 (the head's immediate parent, the first PR commit)
  • head b57d5a0cc544c4dc5bb4764bded9f8eb1b271eb8

Environment

  • Windows 11 10.0.26200, rustc/cargo 1.98.1, d3d10warp.dll 10.0.26100.9818.
  • The machine has one physical GPU. It was not used (see the adapter check below).
  • VICTORY_D3D12_WARP=1, VICTORY_DXIL = Windows SDK 10.0.26100.0 x64\dxil.dll (1.8.2502.11).
  • Target dir D:\victory-3085-warp-target, with -j 4 on every cargo command. D: stayed above 188 GB free.

Adapter check

  • VICTORY_D3D12_WARP only takes effect in a --features diagnostics build (host.rs: cfg!(feature = "diagnostics") && switch::on(...)). A default-feature build ignores it and would use the physical GPU. All repeated runs therefore use --features diagnostics builds only.
  • Before the GPU tests I watched the loaded modules of the test process while it ran.
    • With the variable set: d3d10warp.dll, Microsoft.Internal.WarpPal.dll, d3d12.dll, D3D12Core.dll, dxilconv.dll, and no vendor driver module.
    • Without it (control): amdxc64.dll and amdihk64.dll loaded instead.
  • The existing host::tests::warp_adapter_accepts_only_software printed EnumWarpAdapter: vendor=0x1414, flags=0x2 (Microsoft, software).

Commands

cargo test -p victory-gpu --lib --locked -j 4 --no-run --features diagnostics   # once per commit
<test exe>                                      # whole lib: 246 passed, 1 ignored (247 tests)
<test exe> --test-threads=32
<test exe> shadow:: watch:: marked read_marks marks    # 33 tests: shadow, watch, marked_*, read-mark tests

Runs were interleaved across the three builds. The test executables were run directly, not through cargo test.

Counts (failed runs / runs)

run set base head's parent head
whole lib, default threads 0/40 1/40 0/40
whole lib, --test-threads=32 1/40 0/40 0/40
33-test shadow/watch/mark subset 0/100 0/100 0/100
total 1/180 1/180 0/180

Failures

  • Both failures were the same test, descriptor::host::tests::views_bound_while_another_slot_gets_its_texture_do_not_wait (descriptor/host.rs:2011, "both made"). It is in a file this PR does not touch.
  • It appeared once on base and once on the head's parent, and never on the head in 180 runs. I have not tried to explain it. With 1 failure per build in 180 runs, this does not show the PR changes it.
  • No shadow::, watch:: or mark test failed in any run on any commit.
  • The two tests the PR text says fail on every run on main, memory::tests::lists_share_a_table_and_copies_keep_their_views and descriptor::host::tests::dynamic_slots_are_held_until_released, passed in all 540 runs here.

Limitations

  • WARP only, no physical GPU, so timing and contention differ from the PR author's NVIDIA runs (1 shadow failure in 20 runs on main).
  • 0 failures in 40 default-thread parent runs cannot rule out a flake rate of a few percent.
  • The default-feature build was not run repeatedly, because it would select the physical GPU.
  • Only victory-gpu --lib was run. No other crates, no game, no dumps.
**@⁠oni-swr** on GitHub · 2026-11-26 07:38 UTC · [original](https://github.com/Marvisak/VIctory/pull/3085#issuecomment-7185679957) Independent WARP-only verification of this PR at `b57d5a0cc544c4dc5bb4764bded9f8eb1b271eb8` (claim: https://git.gtahub.st/github/Marvisak--VIctory/issues/1633). Existing tests only, no source edits, no PR. AI use: Claude Code (Claude Sonnet 5.5), coordinated by Codex (gpt-6.2-sol). **Result.** I did not reproduce the shadow/watch/mark flake on the parent under WARP, so these runs neither confirm nor refute the PR's fix. The PR head had no failures in 180 runs. **Compared** - base `63bcca43c6a00a758510398fa43096ce7e4f7df0` (the PR's base) - `46b8c8163580e6717c80cd0938811e16b716e7a0` (the head's immediate parent, the first PR commit) - head `b57d5a0cc544c4dc5bb4764bded9f8eb1b271eb8` **Environment** - Windows 11 10.0.26200, rustc/cargo 1.98.1, `d3d10warp.dll` 10.0.26100.9818. - The machine has one physical GPU. It was not used (see the adapter check below). - `VICTORY_D3D12_WARP=1`, `VICTORY_DXIL` = Windows SDK 10.0.26100.0 `x64\dxil.dll` (1.8.2502.11). - Target dir `D:\victory-3085-warp-target`, with `-j 4` on every cargo command. D: stayed above 188 GB free. **Adapter check** - `VICTORY_D3D12_WARP` only takes effect in a `--features diagnostics` build (`host.rs`: `cfg!(feature = "diagnostics") && switch::on(...)`). A default-feature build ignores it and would use the physical GPU. All repeated runs therefore use `--features diagnostics` builds only. - Before the GPU tests I watched the loaded modules of the test process while it ran. - With the variable set: `d3d10warp.dll`, `Microsoft.Internal.WarpPal.dll`, `d3d12.dll`, `D3D12Core.dll`, `dxilconv.dll`, and no vendor driver module. - Without it (control): `amdxc64.dll` and `amdihk64.dll` loaded instead. - The existing `host::tests::warp_adapter_accepts_only_software` printed `EnumWarpAdapter: vendor=0x1414, flags=0x2` (Microsoft, software). **Commands** ``` cargo test -p victory-gpu --lib --locked -j 4 --no-run --features diagnostics # once per commit <test exe> # whole lib: 246 passed, 1 ignored (247 tests) <test exe> --test-threads=32 <test exe> shadow:: watch:: marked read_marks marks # 33 tests: shadow, watch, marked_*, read-mark tests ``` Runs were interleaved across the three builds. The test executables were run directly, not through `cargo test`. **Counts (failed runs / runs)** | run set | base | head's parent | head | |---|---|---|---| | whole lib, default threads | 0/40 | 1/40 | 0/40 | | whole lib, `--test-threads=32` | 1/40 | 0/40 | 0/40 | | 33-test shadow/watch/mark subset | 0/100 | 0/100 | 0/100 | | total | 1/180 | 1/180 | 0/180 | **Failures** - Both failures were the same test, `descriptor::host::tests::views_bound_while_another_slot_gets_its_texture_do_not_wait` (`descriptor/host.rs:2011`, "both made"). It is in a file this PR does not touch. - It appeared once on base and once on the head's parent, and never on the head in 180 runs. I have not tried to explain it. With 1 failure per build in 180 runs, this does not show the PR changes it. - No `shadow::`, `watch::` or mark test failed in any run on any commit. - The two tests the PR text says fail on every run on main, `memory::tests::lists_share_a_table_and_copies_keep_their_views` and `descriptor::host::tests::dynamic_slots_are_held_until_released`, passed in all 540 runs here. **Limitations** - WARP only, no physical GPU, so timing and contention differ from the PR author's NVIDIA runs (1 shadow failure in 20 runs on main). - 0 failures in 40 default-thread parent runs cannot rule out a flake rate of a few percent. - The default-feature build was not run repeatedly, because it would select the physical GPU. - Only `victory-gpu --lib` was run. No other crates, no game, no dumps.
Author
Owner

@⁠Marvisak on GitHub · 2026-11-26 08:21 UTC · original

Automated triage for the maintainers.

Merge candidate. This changes tests only. watch::tests::free now uses MEM_DECOMMIT (size 0 at the allocation base decommits the whole region) instead of MEM_RELEASE. The address range stays reserved, so a later test's pool cannot land on pages that a leaked tracker still keeps in GUARDS. The new host::tests::no_submissions() holds Host::submitted, the same lock the existing read-mark tests in host.rs hold. The three shadow mark/refresh tests now take it. I checked that their bodies (register, find -> shared_buffer, copy_back_marks) never submit, so they cannot deadlock. Their lock order (submitted, then buffers) is the same as Host::execute's. One cost: test address space is no longer returned, which is fine at these pool sizes.

CI: passing (check).


Generated by Claude Code

**@⁠Marvisak** on GitHub · 2026-11-26 08:21 UTC · [original](https://github.com/Marvisak/VIctory/pull/3085#issuecomment-7186488015) <!-- victory-triage v1 head=b57d5a0cc544c4dc5bb4764bded9f8eb1b271eb8 verdict=merge-candidate at=2026-11-26T08:17:59Z --> Automated triage for the maintainers. **Merge candidate.** This changes tests only. `watch::tests::free` now uses `MEM_DECOMMIT` (size 0 at the allocation base decommits the whole region) instead of `MEM_RELEASE`. The address range stays reserved, so a later test's pool cannot land on pages that a leaked tracker still keeps in `GUARDS`. The new `host::tests::no_submissions()` holds `Host::submitted`, the same lock the existing read-mark tests in `host.rs` hold. The three shadow mark/refresh tests now take it. I checked that their bodies (`register`, `find` -> `shared_buffer`, `copy_back_marks`) never submit, so they cannot deadlock. Their lock order (submitted, then buffers) is the same as `Host::execute`'s. One cost: test address space is no longer returned, which is fine at these pool sizes. CI: passing (check). --- _Generated by [Claude Code](https://claude.ai/code)_
Author
Owner

@⁠fuzeofficlal on GitHub · 2026-11-26 08:40 UTC · original · approved these changes

Clean, test-only fix for both parallel test races:

  • All changes are strictly under #[cfg(test)] (host.rs, shadow.rs, watch.rs), with no production code impact.
  • Checked all watch::tests::free call sites: every caller passes a base allocation from watch::tests::pool, so VirtualFree(p, 0, MEM_DECOMMIT) safely decommits the whole region while keeping its virtual address range reserved so leaked GUARDS entries from other tests cannot poison subsequent pools.
  • Checked all three shadow::tests holding host::tests::no_submissions(): none of them submit command lists or re-enter host.submitted, matching the existing pattern in host::tests.

Verified locally on Windows 11 with default parallel test execution (no --test-threads=1):

  • RTX 5090: cargo test -p victory-gpu --lib -- watch:: shadow:: — 10/10 parallel runs passed (25/25 each)
  • WARP (--features diagnostics, VICTORY_D3D12_WARP=1): watch:: shadow:: — 5/5 parallel runs passed (25/25 each)
  • cargo clippy -p victory-gpu --all-targets -- -D warnings (default and --all-features): clean
  • cargo xtask policy: 191 files ok

LGTM.

**@⁠fuzeofficlal** on GitHub · 2026-11-26 08:40 UTC · [original](https://github.com/Marvisak/VIctory/pull/3085#pullrequestreview-6070844717) · **approved these changes** Clean, test-only fix for both parallel test races: - All changes are strictly under `#[cfg(test)]` (`host.rs`, `shadow.rs`, `watch.rs`), with no production code impact. - Checked all `watch::tests::free` call sites: every caller passes a base allocation from `watch::tests::pool`, so `VirtualFree(p, 0, MEM_DECOMMIT)` safely decommits the whole region while keeping its virtual address range reserved so leaked `GUARDS` entries from other tests cannot poison subsequent pools. - Checked all three `shadow::tests` holding `host::tests::no_submissions()`: none of them submit command lists or re-enter `host.submitted`, matching the existing pattern in `host::tests`. Verified locally on Windows 11 with default parallel test execution (no `--test-threads=1`): - RTX 5090: `cargo test -p victory-gpu --lib -- watch:: shadow::` — 10/10 parallel runs passed (25/25 each) - WARP (`--features diagnostics`, `VICTORY_D3D12_WARP=1`): `watch:: shadow::` — 5/5 parallel runs passed (25/25 each) - `cargo clippy -p victory-gpu --all-targets -- -D warnings` (default and `--all-features`): clean - `cargo xtask policy`: 191 files ok LGTM.
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/3085/head:github-bot/gh-3085'
git switch 'github-bot/gh-3085'

Merge

Merge the changes and update on Forgejo.
git switch 'main'
git merge --no-ff 'github-bot/gh-3085'
git switch 'github-bot/gh-3085'
git rebase 'main'
git switch 'main'
git merge --ff-only 'github-bot/gh-3085'
git switch 'github-bot/gh-3085'
git rebase 'main'
git switch 'main'
git merge --no-ff 'github-bot/gh-3085'
git switch 'main'
git merge --squash 'github-bot/gh-3085'
git switch 'main'
git merge --ff-only 'github-bot/gh-3085'
git switch 'main'
git merge 'github-bot/gh-3085'
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!3085
No description provided.