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

Open
github-bot wants to merge 2 commits from github-bot/gh-462 into a-publier AGit
Owner

@⁠MamaLeVrai on GitHub · 2026-11-27 03:19 UTC · original
MamaLeVrai:more-flakes → a-publier · +31 −5 · 3 files · 2 commits · open

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

**@⁠MamaLeVrai** on GitHub · 2026-11-27 03:19 UTC · [original](https://github.com/Belobug/VIctory-Belobug-AMD/pull/462) `MamaLeVrai:more-flakes` → `a-publier` · +31 −5 · 3 files · 2 commits · open 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)
writes_to_views_are_not_lost unmapped its extra view inside a change of
mapping (title_memory_remapping + title_memory_unmapping, which notes the
block in Guards::changing) and only ended the change after UnmapViewOfFile.
In that window Windows hands the freed address to a watch::tests test
running in parallel; its fresh block is then left_alone() by guard(), never
made read-only, and the test sees it written / writable when it should not
(a_block_just_written_rests, a_write_opens_the_view_it_goes_through, ...),
or loops forever in what_the_title_puts_in_beside_a_guard_is_told.

The view now comes and goes in a one-page placeholder the thread reserves
and keeps (MapViewOfFile3 / UnmapViewOfFile2 with MEM_PRESERVE_PLACEHOLDER),
as no_mapping_is_lost_between_askers already does, so the address is never
another test's. Test-only; the runtime is the sole mapper of title memory.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
views_off_their_elements_get_a_copy_of_their_bytes put its views in a
64 KiB heap Vec, so their place in the 4 MiB loose window that holds them
was wherever the allocator put the Vec. The structured view at start + 8
(456-byte elements) is on its elements in the window whenever
(start % 4 MiB + 8) is a multiple of 456, i.e. for 1 page in 57: it then
rightly takes the window (4194304 bytes wide) and no copy of its own, and
the test failed with "left: 4194304, right: 2048".

The test now moves one page up when the window it would read puts the
view on its elements (4096 is no multiple of 456). Test-only: the
runtime's choice is right for such an address.

On the RX 6950 XT (cargo test --release -p victory-gpu --lib, 8 threads):
before, 3 failures in 60 runs, each with the address on its elements (3 of
the 60 addresses were); forced onto such an address, 5/5 failures with
--test-threads=1; after, 0 failures in 100 runs, and 5/5 passes forced.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
The submission's one asking (ask_once .. ask_once_end) is one for the
process; the runtime makes it under the host's submission lock, so one
submission at a time. Tests make it on their own, in parallel:
unchanged_ranges_are_known, the refresh tests' submission helper (which
had a lock of its own), no_write_is_lost_with_port_7's submission thread
and the_rest_of_the_one_asking_has_a_number_of_its_own.

Two at once lose a write. ask_rest takes the standing ranges out of the
journal, asks the kernel about its own with the journal let go, and puts
both back as one standing asking. A test that ended its asking and wrote
its memory meanwhile then finds its range held again by an asking from
before its write: its ask_ahead_held stops at `kept`, its ask_rest does
not ask about a held range, and nothing_new says nothing changed. Seen in
a probe of a failing run: the standing ranges were the refresh test's
8 pages (as ask_ahead_held joins them) beside port 7's four, kept, its
page 0 noted at asking 5 while copied at 832 (the write at region + 600
never noted). That is "view false: written at its end / on its last
page: left true, right false".

They now take one test-only lock (watch::one_submission) for each such
asking, as the submissions they stand for do.

On the RX 6950 XT, release build, 8 threads:
- unchanged_ranges_are_known with no_write_is_lost_with_port_7:
  5/300 failing runs before, 0/300 after (port 7's own: 0/300 after);
- port 7 with the refresh_tests module: port 7 fails 31/60 before
  ("round N, page P: X is not after X"), 0/60 after; the refresh test
  2/60, then 0/60;
- the refresh test alone: 0/200 before and after;
- the whole lib suite: 0 failures in 100 runs.

Test-only. In the runtime every ask_once/ask_once_end is on the thread
that holds Host::submitted (host.rs submit), so two never overlap; the
take-and-put-back in ask_rest would lose a write only if a second
submitter appeared.

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

@⁠copilot-pull-request-reviewer[bot] on GitHub · 2026-11-27 03:20 UTC · original · reviewed

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.

**@⁠copilot-pull-request-reviewer[bot]** on GitHub · 2026-11-27 03:20 UTC · [original](https://github.com/Belobug/VIctory-Belobug-AMD/pull/462#pullrequestreview-6083027757) · **reviewed** 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.
github-bot force-pushed github-bot/gh-462 from 4ed2b5f6c0 to 68fc5064e1 2026-11-27 05:20:13 +00:00 Compare
Author
Owner

@⁠lvndrpup on GitHub · 2026-11-27 08:53 UTC · original · reviewed

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.

**@⁠lvndrpup** on GitHub · 2026-11-27 08:53 UTC · [original](https://github.com/Belobug/VIctory-Belobug-AMD/pull/462#pullrequestreview-6085644551) · **reviewed** 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 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/462/head:github-bot/gh-462'
git switch 'github-bot/gh-462'

Merge

Merge the changes and update on Forgejo.
git switch 'a-publier'
git merge --no-ff 'github-bot/gh-462'
git switch 'github-bot/gh-462'
git rebase 'a-publier'
git switch 'a-publier'
git merge --ff-only 'github-bot/gh-462'
git switch 'github-bot/gh-462'
git rebase 'a-publier'
git switch 'a-publier'
git merge --no-ff 'github-bot/gh-462'
git switch 'a-publier'
git merge --squash 'github-bot/gh-462'
git switch 'a-publier'
git merge --ff-only 'github-bot/gh-462'
git switch 'a-publier'
git merge 'github-bot/gh-462'
git push origin 'a-publier'
This discussion has been locked. Commenting is limited to contributors.
No description provided.