Watch tests: forget views a test unmaps, so a later allocation there is asked #393

Closed
urielbeaupre wants to merge 660 commits from upstream-pr/393 into main
urielbeaupre commented 2026-11-28 03:13:43 +00:00 (Migrated from github.com)

Imported from TaynanGT/Vice-Tay. Originally posted by urielbeaupre on 2026-11-28T03:13:43Z.


watch::tests::a_raw_copy_in_watched_memory_keeps_the_other_asked_ranges fails at random. Unchanged main, cargo test -p victory-gpu --lib (default thread count), fails in 5 of 30 runs, always with the same panic:

panicked at crates\victory-gpu\src\watch.rs:4559:58: watched destination

Cause

The cause is state an earlier test leaves behind, not two tests racing.

  • The test's fresh allocation sometimes lands at an address where an earlier test had mapped views of a section.
  • That test's cleanup helper (drop_views) unmapped the views without calling title_memory_unmapping, the call that runs forget_views. So the block's VIEWS bit stayed set.
  • ask_ahead_held and ask_rest skip ranges where refused_as_view is true. The new allocation is therefore never asked, and prepare_raw_copy_note returns None.

At a failure, a diagnostic build showed refused_as_view(p) = true with the VIEWS bit set for p's block. In both captured failures, the bit had been set by a_block_just_written_rests (through guard()). That test holds one_asking_test. The bit simply outlives it, so a lock can't fix this, and it only shows when the allocator reuses the address.

Fix

This is test-only. drop_views now tells of the unmapping as the runtime does (title_memory_unmapping) before it unmaps, so what was known of the address as a view goes with it.

Verification

Build Full runs of cargo test -p victory-gpu --lib Failed
main fe7c6e5 30 5 (all the panic above)
with this fix 40 (30 + 10 later) 0

cargo clippy -p victory-gpu --features diagnostics --tests is clean.

Not covered: other helpers may leave stale guard state in other ways. For example, host.rs's title(len, true) never unmaps its views. None of that showed up in these runs. Found while checking a flake reported on #392.

🤖 Generated with Claude Code

<!-- greyfinch-sync:TaynanGT/Vice-Tay:issue:5536126294 --> Imported from [TaynanGT/Vice-Tay](https://github.com/TaynanGT/Vice-Tay/pull/393). Originally posted by [urielbeaupre](https://github.com/urielbeaupre) on 2026-11-28T03:13:43Z. --- `watch::tests::a_raw_copy_in_watched_memory_keeps_the_other_asked_ranges` fails at random. Unchanged main, `cargo test -p victory-gpu --lib` (default thread count), fails in **5 of 30** runs, always with the same panic: ``` panicked at crates\victory-gpu\src\watch.rs:4559:58: watched destination ``` ## Cause The cause is state an earlier test leaves behind, not two tests racing. - The test's fresh allocation sometimes lands at an address where an earlier test had mapped views of a section. - That test's cleanup helper (`drop_views`) unmapped the views without calling `title_memory_unmapping`, the call that runs `forget_views`. So the block's `VIEWS` bit stayed set. - `ask_ahead_held` and `ask_rest` skip ranges where `refused_as_view` is true. The new allocation is therefore never asked, and `prepare_raw_copy_note` returns `None`. At a failure, a diagnostic build showed `refused_as_view(p) = true` with the `VIEWS` bit set for `p`'s block. In both captured failures, the bit had been set by `a_block_just_written_rests` (through `guard()`). That test holds `one_asking_test`. The bit simply outlives it, so a lock can't fix this, and it only shows when the allocator reuses the address. ## Fix This is test-only. `drop_views` now tells of the unmapping as the runtime does (`title_memory_unmapping`) before it unmaps, so what was known of the address as a view goes with it. ## Verification | Build | Full runs of `cargo test -p victory-gpu --lib` | Failed | |---|---|---| | main `fe7c6e5` | 30 | 5 (all the panic above) | | with this fix | 40 (30 + 10 later) | 0 | `cargo clippy -p victory-gpu --features diagnostics --tests` is clean. Not covered: other helpers may leave stale guard state in other ways. For example, `host.rs`'s `title(len, true)` never unmaps its views. None of that showed up in these runs. Found while checking a flake reported on #392. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
Kal0s-design commented 2026-11-28 18:33:53 +00:00 (Migrated from github.com)

Imported from TaynanGT/Vice-Tay. Originally posted by Kal0s-design on 2026-11-28T18:33:53Z.


Independent confirmation from native Windows (NVIDIA card): I chased the same failures today without having seen this PR and landed on the same cause. Tracing why prepare_raw_copy_note refused showed covers=false with the destination's block set in VIEWS, and recording who set that bit pointed at a_write_is_reported_at_every_checked_view via drop_views.

With the same change in drop_views, the test binary run 40 times in a row, parallel:

raw_title_copy_keeps_write_watch_and_resends_equal_bytes a_raw_copy_in_watched_memory_keeps_the_other_asked_ranges
main (fe7c6e5) 6 of 40 3 of 40
with the fix 0 of 40 0 of 40

I opened #425 before noticing this one; closing it in favour of this PR.

AI-assisted: yes

<!-- greyfinch-sync:TaynanGT/Vice-Tay:comment:7243886177 --> Imported from [TaynanGT/Vice-Tay](https://github.com/TaynanGT/Vice-Tay/pull/393#issuecomment-7243886177). Originally posted by [Kal0s-design](https://github.com/Kal0s-design) on 2026-11-28T18:33:53Z. --- Independent confirmation from native Windows (NVIDIA card): I chased the same failures today without having seen this PR and landed on the same cause. Tracing why `prepare_raw_copy_note` refused showed `covers=false` with the destination's block set in `VIEWS`, and recording who set that bit pointed at `a_write_is_reported_at_every_checked_view` via `drop_views`. With the same change in `drop_views`, the test binary run 40 times in a row, parallel: | | `raw_title_copy_keeps_write_watch_and_resends_equal_bytes` | `a_raw_copy_in_watched_memory_keeps_the_other_asked_ranges` | | --- | ---: | ---: | | `main` (`fe7c6e5`) | 6 of 40 | 3 of 40 | | with the fix | 0 of 40 | 0 of 40 | I opened #425 before noticing this one; closing it in favour of this PR. AI-assisted: yes
TaynanGT commented 2026-11-29 11:37:26 +00:00 (Migrated from github.com)

Imported from TaynanGT/Vice-Tay. Originally posted by TaynanGT on 2026-11-29T11:37:26Z.


Thanks for independently finding the same stale VIEWS entry. The 6/40 and 3/40 failures on main versus zero in 40 with the fix are useful. Please keep a deterministic stale-view control alongside the parallel runs so we can distinguish a real fix from a scheduling change.

<!-- greyfinch-sync:TaynanGT/Vice-Tay:comment:7255237868 --> Imported from [TaynanGT/Vice-Tay](https://github.com/TaynanGT/Vice-Tay/pull/393#issuecomment-7255237868). Originally posted by [TaynanGT](https://github.com/TaynanGT) on 2026-11-29T11:37:26Z. --- Thanks for independently finding the same stale VIEWS entry. The 6/40 and 3/40 failures on main versus zero in 40 with the fix are useful. Please keep a deterministic stale-view control alongside the parallel runs so we can distinguish a real fix from a scheduling change.
TaynanGT commented 2026-11-30 17:09:51 +00:00 (Migrated from github.com)

Imported from TaynanGT/Vice-Tay. Originally posted by TaynanGT on 2026-11-30T17:09:51Z.


main has moved to a new line of the code and everything is now named Vice-Tay, so this PR no longer applies as it is (details in #468). If you'd like this change in, please rebuild it on the current main and open a new PR; I'll review it there.

<!-- greyfinch-sync:TaynanGT/Vice-Tay:comment:7285819125 --> Imported from [TaynanGT/Vice-Tay](https://github.com/TaynanGT/Vice-Tay/pull/393#issuecomment-7285819125). Originally posted by [TaynanGT](https://github.com/TaynanGT) on 2026-11-30T17:09:51Z. --- `main` has moved to a new line of the code and everything is now named Vice-Tay, so this PR no longer applies as it is (details in #468). If you'd like this change in, please rebuild it on the current `main` and open a new PR; I'll review it there.

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
TaynanGT/Vice-Tay!393
No description provided.