Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 13 additions & 1 deletion crates/xcl/src/hle/d3d12x/list_x.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7411,7 +7411,19 @@ mod tests {
let n = (*(this as *mut ReentrantGenerationPso)).refs.fetch_sub(1, Ordering::Relaxed) - 1;
let probe = (*(this as *mut ReentrantGenerationPso)).release_outside_lists;
if n == 0 && !probe.is_null() {
(*probe).store(LISTS.try_lock().is_ok(), Ordering::Release);
// LISTS is process-wide, so another test's thread can hold it for a moment; only
// this thread holding it keeps try_lock failing for the whole second.
let deadline = Instant::now() + Duration::from_secs(1);
let outside = loop {
if LISTS.try_lock().is_ok() {
break true;
}
if Instant::now() >= deadline {

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@fromthemoonx fromthemoonx Dec 1, 2026 •

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

break false;
}
std::thread::yield_now();
};
(*probe).store(outside, Ordering::Release);
}
n as u32
}
Expand Down
Loading