GPU tests: isolate WHILE_PREPARING per thread #2932

Closed
github-bot wants to merge 1 commit from gh-pr/2932/head into gh-pr/2932/base
Owner

@⁠alexandruiulian201-bot on GitHub · 2026-11-26 00:26 UTC · original
alexandruiulian201-bot:fix/while-preparing-thread-local → main · +33 −23 · 1 files · 1 commits · closed without merging

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

**@⁠alexandruiulian201-bot** on GitHub · 2026-11-26 00:26 UTC · [original](https://github.com/Marvisak/VIctory/pull/2932) `alexandruiulian201-bot:fix/while-preparing-thread-local` → `main` · +33 −23 · 1 files · 1 commits · closed without merging 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<Work>> 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<Work>>), 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
WHILE_PREPARING was a process-wide Mutex<Option<Work>> read by every HostHeap::mirror -> prepare() call. Under parallel cargo test --workspace --locked, another test can overwrite or take the hook before views_bound_while_another_slot_gets_its_texture_do_not_wait reaches prepare(), causing line 2011 to panic with 'assertion failed: both made' even though WHILE_PREPARING became None.

Both tests that install WHILE_PREPARING trigger prepare() synchronously on the same thread, so storing the hook in thread_local! keeps each test isolated without cross-thread interference.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 05:17:48 +00:00
github-bot closed this pull request 2026-11-26 05:17:48 +00:00
Author
Owner

@⁠alexandruiulian201-bot on GitHub · 2026-11-26 00:35 UTC · original

@⁠kotekompotek Thanks for the heads up! Closing this in favor of #2861 since it was opened first and covers the same WHILE_PREPARING thread_local! fix.

**@⁠alexandruiulian201-bot** on GitHub · 2026-11-26 00:35 UTC · [original](https://github.com/Marvisak/VIctory/pull/2932#issuecomment-7178915598) @⁠kotekompotek Thanks for the heads up! Closing this in favor of #2861 since it was opened first and covers the same `WHILE_PREPARING` `thread_local!` fix.

Pull request closed

This discussion has been locked. Commenting is limited to contributors.
No reviewers
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
github/Marvisak--VIctory!2932
No description provided.