Tests: the generation release probe waits out another test's LISTS lock #3573
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/3573"
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?
Imported from ivall/xcl. Originally posted by fromthemoonx on 2026-12-01T13:54:44Z.
list_x::tests::bundle_generations_propagate_and_final_release_runs_outside_listsfails now and then in parallel runs with "final COM Release ran under LISTS". The test's fakeReleasedecides whether it runs outside LISTS withLISTS.try_lock().is_ok(). LISTS is process-wide, so when another test's thread holds it at that moment, the probe reports a release under LISTS that did not happen. Seen while merge-checking #1421, where it failed onmainas often as on the PR.The probe now retries
try_lockfor up to a second. Another thread lets LISTS go within that time; if this thread holds it, every try fails, so a real release under LISTS is still caught.What is in it
crates/xcl/src/hle/d3d12x/list_x.rs:generation_release(test helper) retriestry_lockuntil a 1 s deadline. Test-only.Tested
cargo test --workspace --no-fail-fast -- --test-threads=4on this branch (e9168f6, onmainb2b1f10): 2902 passed, 0 failed, 51 ignored. SKIPPED: 25 (22 no wave64, 2 no heap windows, 1 no GPU_UPLOAD heaps), the same set as onmain.hle::d3d12x::list_x::tests:: --test-threads=8, 60 runs each: the test failed in 8 of 60 onmainb2b1f10and 0 of 60 with this change. In 2 of the 60 runs with the change,write_buffer_immediate_on_open_existing_heap_visible_to_cpufailed with E_OUTOFMEMORY, a known parallel flake unrelated to this test.clear_segment_statedropping the generations while it still holds LISTS, the test fails with "final COM Release ran under LISTS" (after the 1 s wait), so the check still works.Regression run
#[cfg(test)]helper in a runtime file. Asking a maintainer for thetest-onlylabel.Not tested
AI use
🤖 Generated with Claude Code
Imported from ivall/xcl. Originally posted by gut0to on 2026-12-01T14:44:44Z.
Code review location:
crates/xcl/src/hle/d3d12x/list_x.rs; line 7421This still uses elapsed time as a proxy for lock ownership: another test holding the process-wide
LISTSmutex for more than one second also makesoutsidefalse, so the same flake can recur on a slow or loaded runner. Could this assertion use deterministic coordination with the otherLISTStests (or an explicit same-thread probe) instead of treating the timeout as proof of reentrancy? A test that holds the lock on a second thread across the deadline would cover this case. AI-assisted review; I traced the probe'stry_lockresult against concurrent test ownership.Imported from ivall/xcl. Originally posted by gut0to on 2026-12-01T14:44:44Z.
Review: COMMENTED
AI-assisted review; I used an AI assistant to inspect this diff.
Imported from ivall/xcl. Originally posted by fromthemoonx on 2026-12-01T15:00:43Z.
Code review location:
crates/xcl/src/hle/d3d12x/list_x.rs; line 7421You're right: it is still a timing bound, not a proof. A held lock that outlasts the deadline reads as "released under LISTS", so a test (or a stalled runner) holding
LISTSfor over a second would bring the false failure back.A deterministic same-thread probe needs to know who owns the lock, and
std::sync::Mutexcannot say:try_lockgives the sameWouldBlockwhether this thread or another one holds it. Knowing the owner would take a#[cfg(test)]owner record at every lock site:LISTS.lock()appears 155 times inlist_x.rson mainb2b1f10, all of them runtime code. That is more than this test-only fix should carry, and the change would no longer be test-only.What the deadline changes: before, any overlap with another test's critical section failed the test (8 of 60 module runs at
--test-threads=8); now it takes one held for a whole second, which did not happen in the 60 runs with the change (0 failures); I have not measured how long the tests holdLISTS. If you'd rather have more margin, I can raise the deadline to 10 s: with the bug present the test then takes 10 s to fail, and nothing changes when it passes. A test holding the lock past the deadline on a second thread would show the limit, but it would assert the false result, so I left it out.AI use: Claude Code (Claude Opus 5.5) wrote this reply.
Imported from ivall/xcl. Originally posted by Foniass on 2026-12-01T20:38:13Z.
Review (head
e9168f65, diff read, not a merge-check; checks red):No problems found in the diff. Checked that the change stays inside
#[cfg(test)] mod testsoflist_x.rs, thatclear_segment_state(~1889) drops the generations after theLISTSguard is gone, and that the retry still fails when the releasing thread itself holdsLISTS(atry_lockfrom the holding thread fails on every attempt). Draft #3603 replaces the same line with a shardedLISTS.held(list)check, so whichever lands second conflicts. The red check isPR descriptionasking for smoke blocks becauselist_x.rscounts as a runtime file; thetest-onlylabel is what clears it.AI review: Claude Code (Claude Opus 5.5), posted by Foniass without a human check of each point.
Imported from ivall/xcl. Originally posted by bmjask on 2026-12-02T14:59:03Z.
@Prime1997 could you take a look at this one for review and merge? My automated review notes are above, if any.
View command line instructions
Checkout
From your project repository, check out a new branch and test the changes.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.