GPU tests: isolate WHILE_PREPARING per thread #2930
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/2932"
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 Marvisak/VIctory. Originally posted by alexandruiulian201-bot on 2026-11-26T00:26:51Z.
Problem
Under CI's parallel cargo test --workspace --locked, descriptor::host::tests::views_bound_while_another_slot_gets_its_texture_do_not_wait can flake and panic at crates/victory-gpu/src/descriptor/host.rs:2011 with assertion failed: both made (observed on CI job 139538555053 at
f3578e3).WHILE_PREPARING was a process-wide Mutex<Option> consumed by every HostHeap::mirror -> prepare() call without filtering or serialization:
Another parallel test that sets WHILE_PREPARING (a_slot_rewritten_while_its_view_is_prepared_views_the_new_record) can overwrite the closure before mirror(first, ...) runs, so mirror(second, ...) never executes.
Any other parallel victory-gpu test calling HostHeap::mirror -> prepare() can .take() and run the closure on another thread while the original test thread passes WHILE_PREPARING.is_none() and hits host.kept(second) before the spawned thread completes.
Fix
Store WHILE_PREPARING in thread_local! (RefCell<Option>), matching crates/victory-gpu/src/host.rs's test hook pattern. Both tests that install WHILE_PREPARING trigger prepare() synchronously on the same thread that installs the hook, eliminating cross-thread races while keeping tests parallel.
Verification
cargo clippy -p victory-gpu --all-targets --locked -- -D warnings (default and --all-features): clean
cargo test -p xtask --locked: 6/6 passed (repository_passes_policy ok)
VICTORY_D3D12_WARP=1 cargo test -p victory-gpu --lib --features diagnostics --locked (parallel): 246/246 passed (1 ignored)
10x parallel stress loop on descriptor::host::tests:: (15/15 each run) under WARP + VICTORY_D3D12_DEBUG=1, and 10x parallel stress loop on both WHILE_PREPARING tests on GTX 1070 + VICTORY_D3D12_DEBUG=1: all passed
Imported from Marvisak/VIctory. Originally posted by kotekompotek on 2026-11-26T00:29:37Z.
Review: COMMENTED
Heads up: this is the same fix as #2861 (open) —
WHILE_PREPARINGmoved tothread_local!/RefCellso parallel tests can't steal each other's staged work, including the same call-site updates. Both fix the same CI flake; worth coordinating which one lands.Imported from Marvisak/VIctory. Originally posted by alexandruiulian201-bot on 2026-11-26T00:35:33Z.
@kotekompotek Thanks for the heads up! Closing this in favor of #2861 since it was opened first and covers the same
WHILE_PREPARINGthread_local!fix.Pull request closed