Skip to content

Tests: alloc_pool's outside-STATE checks wait out other tests' holds - #3598

Closed
KDenKC wants to merge 1 commit into
xcl-dev:mainfrom
KDenKC:fix/alloc-pool-test-lock
Closed

KDenKC wants to merge 1 commit into
xcl-dev:mainfrom
KDenKC:fix/alloc-pool-test-lock

Conversation

@KDenKC

@KDenKC KDenKC commented Dec 1, 2026 •

Copy link
Copy Markdown
Contributor

alloc_pool::tests::submit_marking_calls_out_unlocked_and_revalidates_the_queue_marker fails intermittently on main. It, and completion_queries_run_outside_allocator_state, check that a call runs outside the allocator pool's STATE lock with one STATE.try_lock(). That fails whenever another test running beside it holds STATE at that moment (other alloc_pool tests, and list_x / real tests that reach it through the runtime), whatever the code under test does.

The check now retries for up to a second. Held by the calling thread, try_lock never succeeds, so a call made inside STATE still fails the test; held for a moment by another test, the retry waits it out. transferred_owner_is_released_once_outside_state_after_logical_forget in the same file already retried this way (10,000 yields), so it is left as it is.

What is in it (one commit, test code only)

  • crates/xcl/src/hle/d3d12x/alloc_pool.rs, mod tests: outside(&Mutex) (the retrying check), used at the four STATE.try_lock().is_ok() sites of the two tests; a test of the helper: false while this thread holds the lock, true when it is free or held by another thread for 5 ms.

Tested

  • NVIDIA GeForce RTX 5090 (driver 621.40), AMD Ryzen 7 9800X3D, Windows 11 Pro build 26200.9974, Rust 1.99.1 (msvc), debug.
  • The failing test, cargo test -p xcl --lib -- submit_ --test-threads=4 (it runs beside six other alloc_pool tests and the list_x / bind submit tests):
    • main 6bfb5c51: failed 4 of 10 runs.
    • this PR 975a558d: failed 0 of 20 runs.
  • cargo test -p xcl --lib -- alloc_pool --test-threads=4: 28 passed, 0 failed, 0 ignored.
  • cargo test -p xcl --lib -- --test-threads=4, 4 runs: 2757 passed, 0 failed, 31 ignored each (main, 3 runs: 2756 passed, 0 failed, 31 ignored each; this PR adds one test).
  • cargo test --workspace --no-fail-fast -- --test-threads=4: this PR 2901 passed, 4 failed, 51 ignored; main 6bfb5c51 on the same machine 2900 passed, 4 failed, 51 ignored. The same 4 fail on both (incomplete_discovered_corpus_blocks_headless_title_entry, test_title_draws_with_a_root_signature_under_the_debug_layer, test_title_runs_and_game_folder_is_untouched, test_title_runs_under_the_debug_layer_with_dred). SKIPPED on both: 22 GPU tests no wave64, 2 no heap windows, pso_measurement_compiles_an_exact_synthetic_record (Developer Mode off).
  • One earlier whole-lib run on this head ended with exit code 3 and no result line; it did not come back in the 4 whole-lib runs above (nor in main's 3), so its cause is not known.

Regression run

  • None: the diff is test code only (#[cfg(test)] mod tests in alloc_pool.rs); it asks for the test-only label.

Not tested

  • AMD and wave32-only GPUs (the change is CPU-side test code).

AI use

  • Claude Code (Claude Opus 5.5): found the cause, wrote the change, its test and this description; the runs above are from the hardware named.
  • AI use: an agent swarm: Claude Opus 5.5, Claude Sonnet 5.5, GPT-6.2-Sol, Gemini 4 Neon and Gemini 4 Hydrogen.

🤖 Generated with Claude Code

Three alloc_pool tests check that a call runs outside the allocator
pool's STATE lock with one STATE.try_lock(). That fails whenever another
test running beside it holds STATE at that moment, whatever the code under
test does: submit_marking_calls_out_unlocked_and_revalidates_the_queue_marker
failed 4 of 10 runs of 'cargo test -p xcl --lib -- submit_
--test-threads=4' on main 6bfb5c5 (RTX 5090).

The check now retries for up to a second (as the transferred-owner test's
release already did with 10,000 yields): held by the calling thread it
never succeeds, so a call made inside STATE still fails the test. A test of
the helper shows both cases.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@github-actions github-actions Bot added area:d3d12 D3D12.X runtime, command lists, resources, sparse memory area:memory Virtual/physical memory, arenas, VRAM budget, UMA gpu:both Code affects both AMD and NVIDIA GPUs (scope tag; see needs:*-test for remaining checks) needs-pr-check Failing the PR description check (CONTRIBUTING.md) labels Dec 1, 2026
@Foniass

Foniass commented Dec 1, 2026

Copy link
Copy Markdown
Contributor

Review (head 975a558, diff read, not a merge-check; checks red):

  • Duplicate of Tests: alloc_pool checks for STATE held by the caller, not by a parallel test #3190. Tests: alloc_pool checks for STATE held by the caller, not by a parallel test #3190 (open since 2026-11-28, checks green, smoke blocks included) makes the same change at the same four STATE.try_lock().is_ok() sites in alloc_pool.rs (~1771, ~1896, ~1900, ~1958) with a retry helper (state_not_held_by_caller, 10 s deadline), and also fixes the separate late-release race in transferred_owner_is_released_once_outside_state_after_logical_forget (~2178), which this PR leaves as it is.
  • Two different answers about AI use. The first AI use bullet says Claude Code (Claude Opus 5.5) found the cause and wrote the change, test and description; the second says "an agent swarm" of five models. CONTRIBUTING.md asks for the tool, the model and what each did.
  • Commit body and description disagree. The commit body says "Three alloc_pool tests"; the diff and the description change two (completion_queries_run_outside_allocator_state, submit_marking_calls_out_unlocked_and_revalidates_the_queue_marker).

Fine: test-only; a call made while the calling thread holds STATE still fails the check because the helper returns false at its deadline, and the helper test covers the held and briefly-held-elsewhere cases. The red check is PR description asking for smoke blocks (alloc_pool.rs counts as a runtime file).

AI review: Claude Code (Claude Opus 5.5), posted by Foniass without a human check of each point.

@KDenKC

KDenKC commented Dec 1, 2026 •

Copy link
Copy Markdown
Contributor Author

Closing as a duplicate of #3190, which fixes the same four checks plus the late-release race this one leaves. Thanks @Foniass for catching it, and sorry @tiagonleal, our search missed #3190. In case it helps #3190: on an RTX 5090 the submit_ filter loop (--test-threads=4, 10 runs each) failed 4 of 10 on main 6bfb5c51, and 0 of 20 with the retry in place.

AI use: an agent swarm: Claude Opus 5.5, Claude Sonnet 5.5, GPT-6.2-Sol, Gemini 4 Neon and Gemini 4 Hydrogen.

@KDenKC KDenKC closed this Dec 1, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:d3d12 D3D12.X runtime, command lists, resources, sparse memory area:memory Virtual/physical memory, arenas, VRAM budget, UMA gpu:both Code affects both AMD and NVIDIA GPUs (scope tag; see needs:*-test for remaining checks) needs-pr-check Failing the PR description check (CONTRIBUTING.md)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants