Tests: the watch tests' random failures came from a view another test freed mid-change #446
No reviewers
Labels
No labels
accessibility
bug
documentation
duplicate
enhancement
good first issue
help wanted
invalid
question
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/Belobug--VIctory-Belobug-AMD!446
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-446"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
@MamaLeVrai on GitHub · 2026-11-27 02:17 UTC · original
MamaLeVrai:watch-flakes→a-publier· +39 −3 · 1 files · 1 commits · closed without mergingWhat
The
watch::tests::*tests fail at random on this card when the lib suite runs in parallel. A different test fails each time:a_block_just_written_rests,a_write_opens_the_view_it_goes_through,bits_go_at_every_view,what_the_kernel_writes_through_is_not_guarded_for_another_view,written_pages_are_reported_to_every_asker, ... Other testers see the same, and it gets in the way of every PR's report. Sometimeswhat_the_title_puts_in_beside_a_guard_is_toldeven hangs.Cause (test-only):
watch::many_askers_tests::writes_to_views_are_not_losthas a helper thread that maps and unmaps a one-page view 300 times. Each time it frees the address while its mapping change is still open:title_memory_remapping(), thentitle_memory_unmapping(one, PAGE)records the block in the globalGuards::changing, thenUnmapViewOfFile, and only then is the change dropped. In that gap Windows hands the freed address to awatch::teststest running at the same time. Its new block lies insidechanging, soguard()leaves it alone (Guards::left_alone) and never protects it. The block is then always reported as written, and aputloop that waits for the guard spins forever.Fix (test-only, +39/-3): the helper keeps one page reserved as a placeholder of its own. It maps the view there with
MapViewOfFile3(MEM_REPLACE_PLACEHOLDER)and unmaps it withUnmapViewOfFile2(MEM_PRESERVE_PLACEHOLDER), asno_mapping_is_lost_between_askersin the same module already does. The address can no longer go to another test.Production code is not affected. The runtime alone maps title memory, under its mapping lock. Even an address reused during a change would only be reported as written and copied again; no write is lost.
Numbers (RX 6950 XT, Windows 11 build 26300, release)
watch::failurea-publier4eb6cfd, whole lib binary, 8 threadsa-publier,watch::only, 8 threadswatch::only, 8 threadsEvidence for the cause: with
--test-threads=1there are 0 failures in 15 runs;watch::withoutmany_askers_testshas 0 in 20;watch::testswithmany_askers_testshas 11 in 20. A temporary check (not committed) showed that each failing test had its block inside another test's "changing" range.Not fixed here
The remaining rare failures after the fix are other tests:
descriptor::host::tests::views_off_their_elements_get_a_copy_of_their_bytes(also on base, 3 in 78) andhost::refresh_tests::unchanged_ranges_are_known(seen once after the fix, and once on another PR's branch).AI-assisted (Claude Code); no game data.
🤖 Generated with Claude Code
@copilot-pull-request-reviewer[bot] on GitHub · 2026-11-27 02:18 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.
@MamaLeVrai on GitHub · 2026-11-27 03:20 UTC · original
#450 fixes the same thing and covers one more test that freed its view during a change, so it should be taken instead of this one. I'm leaving this open only until that is settled, because #462 sits on it.
AI-assisted (Claude Code); no game data.
@lvndrpup on GitHub · 2026-11-27 03:31 UTC · original · reviewed
Tested on an RTX 3060 Ti 8 GB, Ryzen 5 5600X, 32 GB, Windows 11 build 26300, Rust 1.98.1, debug,
2f18312merged with #382 (3ed1953):watch::,a-publier+ #382, without this PR's changewatch::, the same with this PR's change (and #450's)watch:: host::refresh_tests,a-publier+ #446 + #382I found the same cause and opened #450 eight minutes after you. Yours came first, so I have cut #450 down to the one thing this leaves.
tests::nothing_is_guarded_between_our_forgetting_it_and_its_unmappingalso unmaps its view beforedrop(changing), and #450 now only moves that unmap after the drop. The two PRs touch different tests and merge in either order.One nit:
holeis not released after the 300 rounds, so its page stays reserved for the rest of the test process. That's harmless, but aVirtualFree(hole as *mut _, 0, MEM_RELEASE)after the loop would tidy it.@lvndrpup on GitHub · 2026-11-27 04:35 UTC · original
Update: my review above is out of date. Following MamaLeVrai's comment, #450 carries the full fix again (
391d2a9, both tests), so this PR can be closed in its favour.@MamaLeVrai on GitHub · 2026-11-27 05:11 UTC · original
Closing in favor of #450, which carries the full fix (both tests). #462 is being rebased so it no longer sits on this commit.
AI-assisted (Claude Code); no game data.
Pull request closed