Repository navigation
Tests: the generation release probe waits out another test's LISTS lock - #3573
fromthemoonx wants to merge 1 commit into
Conversation
`bundle_generations_propagate_and_final_release_runs_outside_lists` checks that the final COM Release of a native generation runs outside LISTS by calling `LISTS.try_lock()` inside the fake Release. LISTS is process-wide, so when another test's thread holds it at that moment the probe reports "final COM Release ran under LISTS" although the release ran outside it. On main b2b1f10 (RTX 3060), `list_x::tests::` at --test-threads=8 failed it in 8 of 60 runs. The probe now retries try_lock for up to a second. Another thread lets LISTS go within that time; this thread holding it makes every try fail, so a release under LISTS is still caught: dropping the generations inside the lock in `clear_segment_state` fails the test (after the 1 s wait). With the change, 0 of 60 module runs failed it. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
gut0to
left a comment
There was a problem hiding this comment.
AI-assisted review; I used an AI assistant to inspect this diff.
| if LISTS.try_lock().is_ok() { | ||
| break true; | ||
| } | ||
| if Instant::now() >= deadline { |
There was a problem hiding this comment.
This still uses elapsed time as a proxy for lock ownership: another test holding the process-wide LISTS mutex for more than one second also makes outside false, so the same flake can recur on a slow or loaded runner. Could this assertion use deterministic coordination with the other LISTS tests (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's try_lock result against concurrent test ownership.
There was a problem hiding this comment.
You'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 LISTS for over a second would bring the false failure back.
A deterministic same-thread probe needs to know who owns the lock, and std::sync::Mutex cannot say: try_lock gives the same WouldBlock whether 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 in list_x.rs on main b2b1f10, 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 hold LISTS. 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.
|
Review (head e9168f6, diff read, not a merge-check; checks red): No problems found in the diff. Checked that the change stays inside AI review: Claude Code (Claude Opus 5.5), posted by Foniass without a human check of each point. |
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