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

Closed
github-bot wants to merge 660 commits from github-bot/gh-393 into main AGit
Owner

@⁠urielbeaupre on GitHub · 2026-11-28 03:13 UTC · original
urielbeaupre:fix/watch-test-views → main · +60017 −5429 · 206 files · 660 commits · closed without merging

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

**@⁠urielbeaupre** on GitHub · 2026-11-28 03:13 UTC · [original](https://github.com/TaynanGT/Vice-Tay/pull/393) `urielbeaupre:fix/watch-test-views` → `main` · +60017 −5429 · 206 files · 660 commits · closed without merging `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)
drop_views unmapped the two_views views without title_memory_unmapping, so their VIEWS bits stayed set; a later test whose allocation landed there had it left out of the asking (a_raw_copy_in_watched_memory_keeps_the_other_asked_ranges: 5 of 30 full runs failed on main, 0 of 40 with this).

Co-Authored-By: Claude Opus 5.5 <[email protected]>
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-28 03:18:11 +00:00
Author
Owner

@⁠Kal0s-design on GitHub · 2026-11-28 18:33 UTC · original

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

**@⁠Kal0s-design** on GitHub · 2026-11-28 18:33 UTC · [original](https://github.com/TaynanGT/Vice-Tay/pull/393#issuecomment-7243886177) 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
Author
Owner

@⁠TaynanGT on GitHub · 2026-11-29 11:37 UTC · original

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** on GitHub · 2026-11-29 11:37 UTC · [original](https://github.com/TaynanGT/Vice-Tay/pull/393#issuecomment-7255237868) 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.
github-bot closed this pull request 2026-11-30 17:14:35 +00:00
Author
Owner

@⁠TaynanGT on GitHub · 2026-11-30 17:09 UTC · original

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.

**@⁠TaynanGT** on GitHub · 2026-11-30 17:09 UTC · [original](https://github.com/TaynanGT/Vice-Tay/pull/393#issuecomment-7285819125) `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

This discussion has been locked. Commenting is limited to contributors.
No description provided.