victory-gpu tests of the global guard state fail at random in parallel (10 tests, real Windows machine): a BESIDE bit outlives its view, and more #321

Open
opened 2026-11-26 16:33:05 +00:00 by github-bot · 4 comments
Owner

@⁠compaccount1-coder on GitHub · 2026-11-26 16:32 UTC · original

Summary

On a real Windows machine, cargo test -p victory-gpu --lib fails now and then on tests of the process-global, address-keyed guard state (watch::tests, and one descriptor::host test). Which test fails changes from run to run, and every one of them passes when run alone. They are not GPU tests, so the CI runners can hit them too (#277 cites one such CI run). When main's CI turns green (#169, #241, #298), these will make the default (parallel) job red at random for PRs that don't touch this code.

Where they came from

I ran every open PR that touches victory-gpu merged onto main (c9c932c), one after another, on an RX 6700 XT (Windows 11, Ryzen 5 9600X, 32 GB). The machine was busy during most of these runs, with a build or a second test run beside the suite. None of these failed in 5 full runs of main's GPU crate. So load makes them more likely, but this is not a GPU or driver matter: these tests don't use the GPU.

Failures in PRs that do not touch this code (64 PR runs so far):

Test Failed in
watch::tests::what_the_kernel_writes_through_is_not_guarded_for_another_view #283, #236, #229, #225, #176 (5 of 64), plus once in 40 runs of #277
watch::tests::freed_memory_leaves_no_notes #179, plus once on #277
watch::tests::other_memory_at_a_guarded_address_keeps_its_protection #212
watch::tests::a_write_through_another_view_is_reported_at_the_guarded_one #205
watch::tests::a_write_opens_the_view_it_goes_through #131
watch::tests::a_block_just_written_rests #205 (rerun), #277
watch::tests::kernel_reads_into_guarded_blocks_after_opening #205 (rerun), #277
watch::tests::bits_go_at_every_view #277
host::refresh_tests::unchanged_ranges_are_known #283 (rerun)
descriptor::host::tests::views_off_their_elements_get_a_copy_of_their_bytes 3 times in 49 runs of #277

The PRs named here were each rerun: the failing test passes 5/5 alone, and most full reruns are clean.

One hang: what_the_title_puts_in_beside_a_guard_is_told spins in its unbounded put_beside retry when put_beside keeps answering Cannot. That happened twice in early runs of #277 and never in 40 later ones. #315 makes that loop fail after 30 s with what put_beside looks at, instead of hanging the job.

What I checked about the cause

#277 makes the case that a test's fresh memory can land on an address another test just gave back and inherit its notes. One mechanism of that kind is confirmed here:

  • put_beside sets BESIDE for every view of the page. guard() clears it with BESIDE.take when it next refreshes the block.
  • If the views are unmapped first, nothing clears it. title_memory_changed (behind title_memory_remapped and title_memory_unmapping) and title_memory_freed clear the block's absent/held/foreign/aliased notes, but not BESIDE.
  • A scratch test showed it: put beside, drop_views, then the next two_views(BLOCK). Windows handed back the same two addresses, and BESIDE was still set on both.

In the runtime that costs at most one spare refresh, because the remapped block is reported anyway. For the tests it is the kind of leftover #277 clears with title_memory_made_anew. But #277 calls that from title(), with_holes() and placeholder(), not from watch::tests::two_views(), where most of the tests above get their memory.

It doesn't explain everything, though. The new memory's first guard() takes the stale bit, and what_the_kernel_writes_through… fails at its second guard() (watch.rs:5051, left: Some([page]) right: Some([])). So something must mark the page between the two calls while another test is running. I haven't pinned down what.

Options

  1. Extend #277 to two_views() (and to any other helper that makes memory for these tests), and clear BESIDE there too. #277's helper already clears it.
  2. Serialize the tests that use the global guard state (a shared test mutex in watch::tests and host::refresh_tests) until the cross-test leaks are found.
  3. Or run victory-gpu's lib tests with --test-threads=1 in CI. The diagnostics job already does.

If it helps, I can run any candidate fix through the same loop on this machine and report the counts.

AI-assisted: yes (Claude Code)

**@⁠compaccount1-coder** on GitHub · 2026-11-26 16:32 UTC · [original](https://github.com/avatarmanz/VIctory-7900XTX/issues/321) ## Summary On a real Windows machine, `cargo test -p victory-gpu --lib` fails now and then on tests of the process-global, address-keyed guard state (`watch::tests`, and one `descriptor::host` test). Which test fails changes from run to run, and every one of them passes when run alone. They are not GPU tests, so the CI runners can hit them too (#277 cites one such CI run). When main's CI turns green (#169, #241, #298), these will make the default (parallel) job red at random for PRs that don't touch this code. ## Where they came from I ran every open PR that touches `victory-gpu` merged onto `main` (`c9c932c`), one after another, on an RX 6700 XT (Windows 11, Ryzen 5 9600X, 32 GB). The machine was busy during most of these runs, with a build or a second test run beside the suite. None of these failed in 5 full runs of `main`'s GPU crate. So load makes them more likely, but this is not a GPU or driver matter: these tests don't use the GPU. **Failures in PRs that do not touch this code** (64 PR runs so far): | Test | Failed in | |---|---| | `watch::tests::what_the_kernel_writes_through_is_not_guarded_for_another_view` | #283, #236, #229, #225, #176 (5 of 64), plus once in 40 runs of #277 | | `watch::tests::freed_memory_leaves_no_notes` | #179, plus once on #277 | | `watch::tests::other_memory_at_a_guarded_address_keeps_its_protection` | #212 | | `watch::tests::a_write_through_another_view_is_reported_at_the_guarded_one` | #205 | | `watch::tests::a_write_opens_the_view_it_goes_through` | #131 | | `watch::tests::a_block_just_written_rests` | #205 (rerun), #277 | | `watch::tests::kernel_reads_into_guarded_blocks_after_opening` | #205 (rerun), #277 | | `watch::tests::bits_go_at_every_view` | #277 | | `host::refresh_tests::unchanged_ranges_are_known` | #283 (rerun) | | `descriptor::host::tests::views_off_their_elements_get_a_copy_of_their_bytes` | 3 times in 49 runs of #277 | The PRs named here were each rerun: the failing test passes 5/5 alone, and most full reruns are clean. **One hang:** `what_the_title_puts_in_beside_a_guard_is_told` spins in its unbounded `put_beside` retry when `put_beside` keeps answering `Cannot`. That happened twice in early runs of #277 and never in 40 later ones. #315 makes that loop fail after 30 s with what `put_beside` looks at, instead of hanging the job. ## What I checked about the cause #277 makes the case that a test's fresh memory can land on an address another test just gave back and inherit its notes. One mechanism of that kind is confirmed here: - `put_beside` sets `BESIDE` for every view of the page. `guard()` clears it with `BESIDE.take` when it next refreshes the block. - If the views are unmapped first, nothing clears it. `title_memory_changed` (behind `title_memory_remapped` and `title_memory_unmapping`) and `title_memory_freed` clear the block's `absent`/`held`/`foreign`/`aliased` notes, but not `BESIDE`. - A scratch test showed it: put beside, `drop_views`, then the next `two_views(BLOCK)`. Windows handed back the same two addresses, and `BESIDE` was still set on both. In the runtime that costs at most one spare refresh, because the remapped block is reported anyway. For the tests it is the kind of leftover #277 clears with `title_memory_made_anew`. But #277 calls that from `title()`, `with_holes()` and `placeholder()`, not from `watch::tests::two_views()`, where most of the tests above get their memory. It doesn't explain everything, though. The new memory's first `guard()` takes the stale bit, and `what_the_kernel_writes_through…` fails at its second `guard()` (watch.rs:5051, `left: Some([page]) right: Some([])`). So something must mark the page between the two calls while another test is running. I haven't pinned down what. ## Options 1. Extend #277 to `two_views()` (and to any other helper that makes memory for these tests), and clear `BESIDE` there too. #277's helper already clears it. 2. Serialize the tests that use the global guard state (a shared test mutex in `watch::tests` and `host::refresh_tests`) until the cross-test leaks are found. 3. Or run `victory-gpu`'s lib tests with `--test-threads=1` in CI. The diagnostics job already does. If it helps, I can run any candidate fix through the same loop on this machine and report the counts. AI-assisted: yes (Claude Code)
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 16:33:05 +00:00
Author
Owner

@⁠felicerosella on GitHub · 2026-11-26 18:02 UTC · original

Results on NVIDIA for the open fixes, alone and together: cargo test -p victory-gpu --lib, parallel (default threads), on an RTX 4070 SUPER, Ryzen 7 7800X3D (16 threads), 64 GB, Windows 11 26200, main at c9c932c/2de9980 (victory-gpu is the same in both).

tree clean runs failures
main 15/20 no_write_is_lost_with_port_7 2, unchanged_ranges_are_known 1, other_memory_at_a_guarded_address_keeps_its_protection 1, records_copied_as_bytes_are_made_at_the_next_sync 1
#328 alone 13/20 no_write_is_lost_with_port_7 5, unchanged_ranges_are_known 1, freed_memory_leaves_no_notes 1
#342 alone 19/20 what_is_left_alone_is_no_known_hole 1
#328 + #342 + #277 49/50 a_view_being_split_leaves_its_pages_unguarded_elsewhere 1 (run 47)
  • #342 is the submission part. refreshed_ranges_hold_title_memory's ask_once ended other tests' standing asking. It accounts for no_write_is_lost_with_port_7, a new test that isn't in the list above and fails 20/20 when run with that one test, and for unchanged_ranges_are_known.
  • #277 covers the stale foreign/PUBLISHED notes in fresh test memory. #328 covers the stale BESIDE bit found in this issue, and also clears it in the runtime.
  • #328 and #277 each add a function right after forget_views in watch.rs. Whichever lands second needs a trivial rebase: keep both functions.

Together the three take this machine from about 1 failing run in 4 to 1 in 50. The one failure left, a_view_being_split_leaves_its_pages_unguarded_elsewhere, came once in 50 runs: too rare to bisect from here. I haven't tried them on AMD, or on the CI runners with WARP.

AI-assisted: yes (Claude Code)

**@⁠felicerosella** on GitHub · 2026-11-26 18:02 UTC · [original](https://github.com/avatarmanz/VIctory-7900XTX/issues/321#issuecomment-7199993506) Results on NVIDIA for the open fixes, alone and together: `cargo test -p victory-gpu --lib`, parallel (default threads), on an RTX 4070 SUPER, Ryzen 7 7800X3D (16 threads), 64 GB, Windows 11 26200, `main` at `c9c932c`/`2de9980` (`victory-gpu` is the same in both). | tree | clean runs | failures | |---|---|---| | `main` | 15/20 | `no_write_is_lost_with_port_7` 2, `unchanged_ranges_are_known` 1, `other_memory_at_a_guarded_address_keeps_its_protection` 1, `records_copied_as_bytes_are_made_at_the_next_sync` 1 | | #328 alone | 13/20 | `no_write_is_lost_with_port_7` 5, `unchanged_ranges_are_known` 1, `freed_memory_leaves_no_notes` 1 | | #342 alone | 19/20 | `what_is_left_alone_is_no_known_hole` 1 | | #328 + #342 + #277 | 49/50 | `a_view_being_split_leaves_its_pages_unguarded_elsewhere` 1 (run 47) | - #342 is the submission part. `refreshed_ranges_hold_title_memory`'s `ask_once` ended other tests' standing asking. It accounts for `no_write_is_lost_with_port_7`, a new test that isn't in the list above and fails 20/20 when run with that one test, and for `unchanged_ranges_are_known`. - #277 covers the stale `foreign`/`PUBLISHED` notes in fresh test memory. #328 covers the stale `BESIDE` bit found in this issue, and also clears it in the runtime. - #328 and #277 each add a function right after `forget_views` in `watch.rs`. Whichever lands second needs a trivial rebase: keep both functions. Together the three take this machine from about 1 failing run in 4 to 1 in 50. The one failure left, `a_view_being_split_leaves_its_pages_unguarded_elsewhere`, came once in 50 runs: too rare to bisect from here. I haven't tried them on AMD, or on the CI runners with WARP. AI-assisted: yes (Claude Code)
Author
Owner

@⁠kilolimaVI on GitHub · 2026-11-26 20:05 UTC · original · edited 2026-11-26 20:09 UTC

AMD data point (Radeon 780M iGPU, RDNA3, Ryzen 7 8845HS, Windows 11, toolchain 1.98.1): full cargo test -p victory-gpu --lib --locked, default parallel threads, 20 runs per variant.

Deterministic on this GPU, every run of every variant (so not part of the race): descriptor::host::tests::views_are_made_beside_the_heap_and_copied_in fails at descriptor/host.rs:5434 ("copied as it was made"): the staged view's bytes differ from the slot's on this card. This test came in with 02f36e4 and may assume something about the 7900 XTX's descriptors.

Intermittent failures besides that one:

variant failures in 20 runs
main watch::port7_tests::no_write_is_lost_with_port_7 4x
#342 kernel_reads_into_guarded_blocks_after_opening 2x, views_off_their_elements_get_a_copy_of_their_bytes 1x, a_view_being_split_leaves_its_pages_unguarded_elsewhere 1x, what_is_put_in_beside_the_guards_is_told_at_every_view 1x
#347 none
#342 + #328 (merged locally, clean) views_off_their_elements_get_a_copy_of_their_bytes 2x

#347 conflicts with #342 in host.rs, so #347 + #342 wasn't run. 20 runs is a small sample; happy to run more on any combination.

**@⁠kilolimaVI** on GitHub · 2026-11-26 20:05 UTC · [original](https://github.com/avatarmanz/VIctory-7900XTX/issues/321#issuecomment-7202284685) · edited 2026-11-26 20:09 UTC AMD data point (Radeon 780M iGPU, RDNA3, Ryzen 7 8845HS, Windows 11, toolchain 1.98.1): full `cargo test -p victory-gpu --lib --locked`, default parallel threads, 20 runs per variant. Deterministic on this GPU, every run of every variant (so not part of the race): `descriptor::host::tests::views_are_made_beside_the_heap_and_copied_in` fails at `descriptor/host.rs:5434` ("copied as it was made"): the staged view's bytes differ from the slot's on this card. This test came in with 02f36e4 and may assume something about the 7900 XTX's descriptors. Intermittent failures besides that one: | variant | failures in 20 runs | |---|---| | main | `watch::port7_tests::no_write_is_lost_with_port_7` 4x | | #342 | `kernel_reads_into_guarded_blocks_after_opening` 2x, `views_off_their_elements_get_a_copy_of_their_bytes` 1x, `a_view_being_split_leaves_its_pages_unguarded_elsewhere` 1x, `what_is_put_in_beside_the_guards_is_told_at_every_view` 1x | | #347 | none | | #342 + #328 (merged locally, clean) | `views_off_their_elements_get_a_copy_of_their_bytes` 2x | #347 conflicts with #342 in `host.rs`, so #347 + #342 wasn't run. 20 runs is a small sample; happy to run more on any combination.
Author
Owner

@⁠ending3729 on GitHub · 2026-11-26 22:03 UTC · original

Thanks for the AMD 780M data point @⁠kilolimaVI!

Since your run I pushed two small follow-up fixes to #347 (8a86a45 for the 1-in-75 drop_views/g.changing race @⁠felicerosella caught on NVIDIA, and 3345a6d for a 1-in-100 ABA race in look_at_holes that showed up in no_mapping_is_lost_between_askers).

On 3345a6d, cargo test -p victory-gpu --lib --locked -- --skip views_are_made_beside_the_heap_and_copied_in just passed 100/100 consecutive parallel runs on my RX 6600 XT / Ryzen 5 7500F (Windows 11). If you feel like doing a bigger batch on the 780M, 3345a6d is the latest — no pressure either way.

**@⁠ending3729** on GitHub · 2026-11-26 22:03 UTC · [original](https://github.com/avatarmanz/VIctory-7900XTX/issues/321#issuecomment-7204309051) Thanks for the AMD 780M data point @⁠kilolimaVI! Since your run I pushed two small follow-up fixes to `#347` (`8a86a45` for the 1-in-75 `drop_views`/`g.changing` race @⁠felicerosella caught on NVIDIA, and `3345a6d` for a 1-in-100 ABA race in `look_at_holes` that showed up in `no_mapping_is_lost_between_askers`). On `3345a6d`, `cargo test -p victory-gpu --lib --locked -- --skip views_are_made_beside_the_heap_and_copied_in` just passed **100/100** consecutive parallel runs on my RX 6600 XT / Ryzen 5 7500F (Windows 11). If you feel like doing a bigger batch on the 780M, `3345a6d` is the latest — no pressure either way.
Author
Owner

@⁠kilolimaVI on GitHub · 2026-11-27 10:52 UTC · original

@⁠ending3729 100-run batch on the latest head of #347, 14cdb13 (so including 3345a6d and the 14cdb13 follow-up): AMD Radeon 780M (RDNA3 iGPU), Ryzen 7 8845HS, Windows 11, toolchain 1.98.1.

cargo test -p victory-gpu --lib --locked -- --skip views_are_made_beside_the_heap_and_copied_in, default parallel threads: 0/100 failures.

For comparison, on main the same suite had no_write_is_lost_with_port_7 fail 4 times in 20 runs here. The skipped test is the one that fails deterministically on this card (descriptor/host.rs:5434), unrelated to the race.

AI-assisted (Claude).

**@⁠kilolimaVI** on GitHub · 2026-11-27 10:52 UTC · [original](https://github.com/avatarmanz/VIctory-7900XTX/issues/321#issuecomment-7216413976) @⁠ending3729 100-run batch on the latest head of #347, 14cdb13 (so including 3345a6d and the 14cdb13 follow-up): AMD Radeon 780M (RDNA3 iGPU), Ryzen 7 8845HS, Windows 11, toolchain 1.98.1. `cargo test -p victory-gpu --lib --locked -- --skip views_are_made_beside_the_heap_and_copied_in`, default parallel threads: **0/100 failures**. For comparison, on main the same suite had `no_write_is_lost_with_port_7` fail 4 times in 20 runs here. The skipped test is the one that fails deterministically on this card (`descriptor/host.rs:5434`), unrelated to the race. AI-assisted (Claude).
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/avatarmanz--VIctory-7900XTX#321
No description provided.