Tests: two more random failures in victory-gpu (an allocator-placed view, a shared write-watch asking) #462

Open
MamaLeVrai wants to merge 2 commits from upstream-pr/462 into a-publier
MamaLeVrai commented 2026-11-27 03:19:56 +00:00 (Migrated from github.com)

Imported from Belobug/VIctory-Belobug-AMD. Originally posted by MamaLeVrai on 2026-11-27T03:19:56Z.


Independent of the watch fix (#450): rebased onto a-publier 4eb6cfd, commits 281b850 and 68fc506 (the numbers below were measured on top of the #446 placeholder fix, which #450 carries too). Two more random failures of cargo test -p victory-gpu --lib, both test-only.

1. descriptor::host::tests::views_off_their_elements_get_a_copy_of_their_bytes (e34c1cc)

Cause: the result depends on where the allocator puts the test's 64 KiB Vec, not on another test. With no registered buffer, the runtime copies the surrounding 4 MiB block of memory (shadow::window_of / loose). The structured view at start+8 has 456-byte elements. When its offset in that block is a multiple of 456, off_elements correctly says it is on its elements, uses the 4 MiB copy, and the width comes out as 4194304 instead of 2048. That happens for about 1 page in 57. In 60 runs exactly 3 addresses fell on such a page, and those were exactly the 3 failures. Forcing such an address fails 5 of 5 even with --test-threads=1.

Fix: if the block's copy would put the view on its elements, the test moves up one page (4096 is not a multiple of 456). The runtime's choice is right for such an address, so there is nothing to change there.

Before/after: 3 of 60 full-suite runs -> 0 of 100; a forced address fails 5 of 5 -> passes 5 of 5.

2. host::refresh_tests::unchanged_ranges_are_known (4ed2b5f)

Cause: the submission's single write-watch asking (ask_once ... ask_once_end) is one state for the whole process. ask_rest takes the standing ranges out, releases the lock while it asks the kernel, and puts them back together with its own. Run beside watch::port7_tests::no_write_is_lost_with_port_7, one test's ended asking can come back inside the other's. The next ask_once then asks nothing (ask_ahead_held sees an asking standing), and a write goes unseen: view false: written at its end, left: true, right: false.

Fix: a test-only lock, watch::one_submission(), held for each such asking by the four tests that make one. These are this test, the refresh tests' submission() helper (which had a lock of its own), port 7's submission thread, and the_rest_of_the_one_asking_has_a_number_of_its_own.

Not a live race: every ask_once / ask_once_end in the runtime is inside Host::submit, under the submitted lock (settle_stale, run_deferred and the batch flushes included). Two submissions never overlap.

Run (RX 6950 XT, release) before after
this test + port 7, 300 runs 5 0
refresh_tests + port 7, 60 runs: this test / the port 7 test 2 / 31 0 / 0
this test alone, 200 runs 0 0
whole lib binary, 8 threads (see #446) 0 of 100, and 0 of 25 rechecked

It also ends port 7's own flake (round N, page P: X is not after X) when it runs beside the refresh tests.

Still seen: watch::tests::other_memory_at_a_guarded_address_keeps_its_protection failed 2 of 100 when only refresh_tests and watch:: ran together, never in whole-suite runs. Not fixed here. Clippy (-p victory-gpu --all-targets) is clean.

AI-assisted (Claude Code); no game data.

🤖 Generated with Claude Code

<!-- greyfinch-sync:Belobug/VIctory-Belobug-AMD:issue:5520596729 --> Imported from [Belobug/VIctory-Belobug-AMD](https://github.com/Belobug/VIctory-Belobug-AMD/pull/462). Originally posted by [MamaLeVrai](https://github.com/MamaLeVrai) on 2026-11-27T03:19:56Z. --- Independent of the `watch` fix (#450): rebased onto `a-publier` `4eb6cfd`, commits `281b850` and `68fc506` (the numbers below were measured on top of the #446 placeholder fix, which #450 carries too). Two more random failures of `cargo test -p victory-gpu --lib`, both test-only. ## 1. `descriptor::host::tests::views_off_their_elements_get_a_copy_of_their_bytes` (`e34c1cc`) **Cause:** the result depends on where the allocator puts the test's 64 KiB `Vec`, not on another test. With no registered buffer, the runtime copies the surrounding 4 MiB block of memory (`shadow::window_of` / `loose`). The structured view at `start+8` has 456-byte elements. When its offset in that block is a multiple of 456, `off_elements` correctly says it is on its elements, uses the 4 MiB copy, and the width comes out as 4194304 instead of 2048. That happens for about 1 page in 57. In 60 runs exactly 3 addresses fell on such a page, and those were exactly the 3 failures. Forcing such an address fails 5 of 5 even with `--test-threads=1`. **Fix:** if the block's copy would put the view on its elements, the test moves up one page (4096 is not a multiple of 456). The runtime's choice is right for such an address, so there is nothing to change there. **Before/after:** 3 of 60 full-suite runs -> 0 of 100; a forced address fails 5 of 5 -> passes 5 of 5. ## 2. `host::refresh_tests::unchanged_ranges_are_known` (`4ed2b5f`) **Cause:** the submission's single write-watch asking (`ask_once` ... `ask_once_end`) is one state for the whole process. `ask_rest` takes the standing ranges out, releases the lock while it asks the kernel, and puts them back together with its own. Run beside `watch::port7_tests::no_write_is_lost_with_port_7`, one test's ended asking can come back inside the other's. The next `ask_once` then asks nothing (`ask_ahead_held` sees an asking standing), and a write goes unseen: `view false: written at its end`, `left: true, right: false`. **Fix:** a test-only lock, `watch::one_submission()`, held for each such asking by the four tests that make one. These are this test, the refresh tests' `submission()` helper (which had a lock of its own), port 7's submission thread, and `the_rest_of_the_one_asking_has_a_number_of_its_own`. **Not a live race:** every `ask_once` / `ask_once_end` in the runtime is inside `Host::submit`, under the `submitted` lock (`settle_stale`, `run_deferred` and the batch flushes included). Two submissions never overlap. | Run (RX 6950 XT, release) | before | after | |---|---|---| | this test + port 7, 300 runs | 5 | 0 | | `refresh_tests` + port 7, 60 runs: this test / the port 7 test | 2 / 31 | 0 / 0 | | this test alone, 200 runs | 0 | 0 | | whole lib binary, 8 threads | (see #446) | 0 of 100, and 0 of 25 rechecked | It also ends port 7's own flake (`round N, page P: X is not after X`) when it runs beside the refresh tests. Still seen: `watch::tests::other_memory_at_a_guarded_address_keeps_its_protection` failed 2 of 100 when only `refresh_tests` and `watch::` ran together, never in whole-suite runs. Not fixed here. Clippy (`-p victory-gpu --all-targets`) is clean. AI-assisted (Claude Code); no game data. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
copilot-pull-request-reviewer[bot] commented 2026-11-27 03:20:09 +00:00 (Migrated from github.com)

Imported from Belobug/VIctory-Belobug-AMD. Originally posted by copilot-pull-request-reviewer[bot] on 2026-11-27T03:20:09Z.

Review: COMMENTED


Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota. Try requesting a review at a lower effort level.

<!-- greyfinch-sync:Belobug/VIctory-Belobug-AMD:review:6083027757 --> Imported from [Belobug/VIctory-Belobug-AMD](https://github.com/Belobug/VIctory-Belobug-AMD/pull/462#pullrequestreview-6083027757). Originally posted by [copilot-pull-request-reviewer[bot]](https://github.com/apps/copilot-pull-request-reviewer) on 2026-11-27T03:20:09Z. **Review:** COMMENTED --- Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota. Try requesting a review at a lower effort level.
lvndrpup commented 2026-11-27 08:53:55 +00:00 (Migrated from github.com)

Imported from Belobug/VIctory-Belobug-AMD. Originally posted by lvndrpup on 2026-11-27T08:53:55Z.

Review: COMMENTED


Tested on an RTX 3060 Ti 8 GB, Ryzen 5 5600X, Windows 11 build 26300, Rust 1.98.1, debug, on 68fc506.

Overlap with #382. The second commit (68fc506) makes the same change as #382: a test-only lock in the same four places (refresh_tests::submission, the look in unchanged_ranges_are_known, port 7's submission thread, and the_rest_of_the_one_asking_has_a_number_of_its_own). It is called submission_in_test there and one_submission here. The two PRs conflict in host.rs and watch.rs, so only one of them can go in as it is.

A caller neither PR covers. host::card_steps::tests::the_card_copies_what_is_recorded is not ignored and submits through host.execute (card_steps.rs:1202). HostQueue::submit then calls watch::ask_once (host.rs:5840) and ask_once_end (host.rs:5898) without the lock. So "Not a live race" holds for the runtime, but this test runs one real submission beside the others. let _one = crate::watch::one_submission(); at the top of that test would close it. submit never takes the lock, so this cannot deadlock. The details are in my comment on #382.

Runs of cargo test -p victory-gpu --lib -- watch:: host::refresh_tests (52 tests), with the two builds alternating:

#462 merged with runs failed
#446 (2f18312, the placeholder half only) 200 0
#450 (391d2a9) 200 1, in watch::many_askers_tests::no_mapping_is_lost_between_askers

watch::many_askers_tests on its own, 500 runs of each build: 0 failures in both. other_memory_at_a_guarded_address_keeps_its_protection failed in none of these runs. I could not get the one failure above again, and its panic text was not kept. I found nothing in #450 that reaches that test either: its placeholder stays reserved for the whole test.

Not tested: the descriptor commit (281b850) and the whole suite.

<!-- greyfinch-sync:Belobug/VIctory-Belobug-AMD:review:6085644551 --> Imported from [Belobug/VIctory-Belobug-AMD](https://github.com/Belobug/VIctory-Belobug-AMD/pull/462#pullrequestreview-6085644551). Originally posted by [lvndrpup](https://github.com/lvndrpup) on 2026-11-27T08:53:55Z. **Review:** COMMENTED --- Tested on an RTX 3060 Ti 8 GB, Ryzen 5 5600X, Windows 11 build 26300, Rust 1.98.1, debug, on `68fc506`. **Overlap with #382.** The second commit (`68fc506`) makes the same change as #382: a test-only lock in the same four places (`refresh_tests::submission`, the `look` in `unchanged_ranges_are_known`, port 7's submission thread, and `the_rest_of_the_one_asking_has_a_number_of_its_own`). It is called `submission_in_test` there and `one_submission` here. The two PRs conflict in `host.rs` and `watch.rs`, so only one of them can go in as it is. **A caller neither PR covers.** `host::card_steps::tests::the_card_copies_what_is_recorded` is not ignored and submits through `host.execute` (`card_steps.rs:1202`). `HostQueue::submit` then calls `watch::ask_once` (`host.rs:5840`) and `ask_once_end` (`host.rs:5898`) without the lock. So "Not a live race" holds for the runtime, but this test runs one real submission beside the others. `let _one = crate::watch::one_submission();` at the top of that test would close it. `submit` never takes the lock, so this cannot deadlock. The details are in my comment on #382. **Runs** of `cargo test -p victory-gpu --lib -- watch:: host::refresh_tests` (52 tests), with the two builds alternating: | #462 merged with | runs | failed | |---|---|---| | #446 (`2f18312`, the placeholder half only) | 200 | 0 | | #450 (`391d2a9`) | 200 | 1, in `watch::many_askers_tests::no_mapping_is_lost_between_askers` | `watch::many_askers_tests` on its own, 500 runs of each build: 0 failures in both. `other_memory_at_a_guarded_address_keeps_its_protection` failed in none of these runs. I could not get the one failure above again, and its panic text was not kept. I found nothing in #450 that reaches that test either: its placeholder stays reserved for the whole test. Not tested: the descriptor commit (`281b850`) and the whole suite.
This pull request cannot be merged automatically due to conflicts.
Merge manually to resolve the conflicts.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin 'upstream-pr/462:upstream-pr/462'
git switch 'upstream-pr/462'

Merge

Merge the changes and update on Forgejo.

Warning: The "Autodetect manual merge" setting is not enabled for this repository, you will have to mark this pull request as manually merged afterwards.

git switch 'a-publier'
git merge --no-ff 'upstream-pr/462'
git switch 'upstream-pr/462'
git rebase 'a-publier'
git switch 'a-publier'
git merge --ff-only 'upstream-pr/462'
git switch 'upstream-pr/462'
git rebase 'a-publier'
git switch 'a-publier'
git merge --no-ff 'upstream-pr/462'
git switch 'a-publier'
git merge --squash 'upstream-pr/462'
git switch 'a-publier'
git merge --ff-only 'upstream-pr/462'
git switch 'a-publier'
git merge 'upstream-pr/462'
git push origin 'a-publier'
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
Belobug/VIctory-Belobug-AMD!462
No description provided.