Tests: alloc_pool checks for STATE held by the caller, not by a parallel test #3190
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/3190"
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 ivall/xcl. Originally posted by tiagonleal on 2026-11-28T17:22:22Z.
Part of #3180. Two
alloc_pooltests failed on CI today on commits that do not touch them:submit_marking_calls_out_unlocked_and_revalidates_the_queue_marker("queue invalidation can run while Signal is outside STATE") andcompletion_queries_run_outside_allocator_state("in-flight polling must not hold STATE").Both check that a callback runs outside
STATEwith a singleSTATE.try_lock().is_ok().STATEis one mutex for the whole process, and the otheralloc_pooltests, which run in parallel, hold it for short stretches. So the singletry_lockfails whenever another test holds the lock at that moment, with nothing wrong in the code under test.A third test in the file,
transferred_owner_is_released_once_outside_state_after_logical_forget, fails under load for a related reason: other tests callforget(), whose sweep runs over every retired backing in the sharedSTATE, so a parallel test can release this test's owner first. The test's own sweep then finds nothing and returns while the other thread is still inside the release, and the check reads(refs, releases) = (1, 0). The owner is still released exactly once; it is not a runtime defect. andrewDoing reproduced this interleaving independently in a comment below.Rebased onto
mainf97120dc.mainadded a test at the place of the helper; both are kept, and the diff is unchanged (+22/-4).What is in it
alloc_pool.rs(test module): a helperstate_not_held_by_caller()retriestry_lockfor up to 10 s, and the four checks use it. Atry_lockfrom the thread that holds the lock never succeeds, so the deadline is reached only when the code really holdsSTATE. Test code only, no assertion removed.transferred_owner_is_released_once_outside_state_after_logical_forgetwaits up to 10 s for the release to arrive before the same assertions as before. +6.Tested
alloc_pooltests run 40 times with--test-threads=32: 31 runs failed, with these two tests panicking 23 and 18 times, at the lines of both CI messages. After: 40 runs, neither test failed.STATEheld around the queueSignaland aroundGetCompletedValuein the code under test (scratch edits, reverted), both fail after 10 s with "queue Signal must run outside STATE" and "in-flight polling must not hold STATE".cargo test -p xcl --lib hle::d3d12x::alloc_pool -- --test-threads=4: 27 passed, 0 failed.cargo test -p xcl --lib alloc_pool -- --test-threads=32, 20 runs on headfb24a2e6: 0 failures.--test-threads=32, each from another test's sweep (released_lists_leave_only_live_recordings_and_gpu_work_holding_the_backing,submit_marking_calls_out_unlocked_and_revalidates_the_queue_markertwice,submit_reservation_drop_and_failure_are_fail_closed,submit_reservation_keeps_pre_reset_attribution_across_queues). The test failed in 2 of 40 and 5 of 40 runs in two earlier loops and 1 of 40 in the loop before this commit; 0 of 40 after.mainf97120dc(head353546c6):cargo test --workspace --no-fail-fast -j 8 -- --test-threads=4, one run: 2841 passed, 0 failed, 51 ignored (24SKIPPEDlines: 22no wave64, 2no heap windows; the same 24 in both logs);mainf97120dcon this machine: 2841 passed, 0 failed, 51 ignored.Regression run
scripts/smoke.ps1 -Seconds 60 -Title 9cc6a39e(Newer Retail Game), release builds in clean trees, one run each,XCL_PREPARE=0, same DXIL cache. No code outside#[cfg(test)]changes; the run is there becausealloc_pool.rsis a runtime file.main(f97120dc):This PR (
353546c6):Not tested
hle::d3d12xtests failed once each when the tests ran with--test-threads=32on an already loaded 16-thread PC; they are listed in #3180 and are not part of this PR.AI use
🤖 Generated with Claude Code
Imported from ivall/xcl. Originally posted by andrewDoing on 2026-11-28T17:33:41Z.
I reproduced one interleaving that explains the remaining
transferred_owner_is_released_once_outside_state_after_logical_forgetcounter failure atbfc9e9fa.With a test-only change to that fixture, I let a competing thread call the actual
sweep_release_owners_withand pause in itsrelease_transferredcallback before dropping the fake allocator. The backing had already been removed underSTATE. The fixture thread then called its own sweep; it returned normally because the backing was gone. At the stock assertion point the fake COM counters were (refs=1, releases=0). I let the competing callback finish and reran the same reads: (0,1), and the existing outside-lock and backing-removal checks passed. Both channel waits were bounded. One focused Windows test passed without skips; no GPU used.A test-local completion notification from the fake allocator callback after its final counter update, with a bounded wait before checking the counters, would preserve the exactly-once check while allowing another sweep to own the release. The production ordering deliberately releases outside the lock. This establishes a possible counter failure on the real sweep path; it does not identify the schedule of the earlier stress failures.
AI use: OpenAI Codex added the focused interleaving, ran the test and prepared this report.
Imported from ivall/xcl. Originally posted by JJAutoCompare on 2026-11-28T17:37:15Z.
Tested
Independently reran the pinned standalone CPU executable for
bfc9e9faffbe0272e8313a76132f6ea2f621283aon Windows 11 x64 build 26200.9974 with a Ryzen 7 3800X. The executable was built with Rust 1.100.1 (x86_64 MSVC). The 328-bytestate_not_held_by_callerhelper matched the Git source byte for byte. The harness used a stand-inMutex<()>forSTATE.Both native processes exited 0. Total was 2 passed, 0 failed, 0 ignored, 0 skipped. With another thread holding the lock,
try_lockreturnedWouldBlockbefore the call, and the helper returnedtrueafter the holder dropped the guard following the fixture's 500 ms delay. With the calling thread holding the lock, the helper returnedfalseat the ten-second deadline. The lock still returnedWouldBlockuntil the caller dropped its guard, and the idle helper check then returnedtrue.Not tested
Real allocator state, the allocator test module, runtime callbacks, D3D12, GPU, retail titles, the workspace suite, performance, and flake rate.
AI use
T3 Code through Codex (
gpt-6.2-sol, high) prepared the standalone fixture, verified the source and executable, independently reran both tests, and drafted this report.Imported from ivall/xcl. Originally posted by tiagonleal on 2026-11-28T18:45:58Z.
@andrewDoing thanks, that is the interleaving. Temporary logging here showed the same thing from the other side: in 40 runs at
--test-threads=32, 5 late releases, each made by another test's sweep after it had taken this test's backing out underSTATE. The second commit (e20411ad) does what you describe in a smaller form: after its own sweep the test waits up to 10 s for the release to arrive and then runs the same assertions. It does not add a completion notification to the fake allocator; if a maintainer prefers that, it is a small change on top.@JJAutoCompare thanks for the check of the helper.
AI use: Claude Code wrote this comment (Claude Fable 5.2); Claude Opus 5.5 ran the loops.
Imported from ivall/xcl. Originally posted by BBareth on 2026-11-30T23:11:24Z.
merge-check claim
head:
353546c6bbImported from ivall/xcl. Originally posted by BBareth on 2026-11-30T23:19:43Z.
merge-check
base:
86e86fcb33head:
353546c6bbmerge: clean
build: cargo build --workspace -> ok
tests: cargo test --workspace --no-fail-fast -- --test-threads=4 -> 2889 passed, 0 failed, 51 ignored; 28 SKIPPED lines, as on the base; failing: none. The base alone, same run: 2889 passed, 0 failed, 51 ignored, 28 SKIPPED lines (22 no wave64, 2 no heap windows, 2 no d3d12SDKLayers.dll, 1 no D3D12 debug layer, 1 cannot disable the driver cache).
review: no blocking finding; test-only, one file (+22/-4), every line read. The four
STATE.try_lock().is_ok()checks go throughstate_not_held_by_caller(), which retries until a 10 s deadline:std::sync::Mutexis not re-entrant, so when the calling thread itself holdsSTATEeverytry_lockfails and the helper still returns false, which keeps the checks meaningful.transferred_owner_is_released_once_outside_state_after_logical_forgetwaits up to 10 s for a release another test's sweep may be finishing, then makes the same(0, 1)assertion as before. Both waits spin withyield_now, so a real failure now takes 10 s of one core before it reports; not blocking. The failures this is for did not occur on the base in this run, so the run shows no regression, not the fix. No runtime code changes.performance: none: tests only.
verdict: safe to merge
hardware / tool and model: RTX 5070 Ti 16 GB, driver 621.24 (32.0.16.2124); i7-12700K; Windows 11 26200. Claude Code, Claude Fable 5.2 read the diff, ran the build and the suite and wrote this check.
Imported from ivall/xcl. Originally posted by Foniass on 2026-12-01T09:42:28Z.
Triage (#1607) – head
353546c#3183 and #3472 are also part of #3180 but touch other tests (pipeline_library serialisation, fake allocator backings in bind.rs/list_x.rs); no open or merged PR changes these four alloc_pool checks or the late-release wait. The helper only retries
try_lockand keeps the 10 s fail path when the caller really holdsSTATE; no problems found in the diff.Recommendation: keep open.
AI review: Claude Code (Claude Opus 5.5), diffs read only, not built or run; not checked by a human.
Imported from ivall/xcl. Originally posted by Foniass on 2026-12-01T10:26:53Z.
merge-check
base:
493dbd3dd0head:
353546c6bbmerge: clean
build: cargo build --workspace -> ok
tests: cargo test --workspace --no-fail-fast -- --test-threads=4 -> 2900 passed, 0 failed, 51 ignored; SKIPPED: 28 (20 no wave64, 2 no d3d12SDKLayers.dll, 1 no D3D12 debug layer, 1 no heap windows, 1 cannot disable the driver cache, 3 others; the same set as on main); failing: none
review: read the whole diff (+22/-4, inside the
alloc_pool.rstest module).state_not_held_by_caller()retriesSTATE.try_lock()for up to 10 s instead of once. Astd::sync::Mutexheld by the calling thread makestry_lockreturnWouldBlockevery time, so a real "called inside STATE" still fails, now after the deadline, as the description's scratch-edit check shows. A lock held briefly by a parallel test no longer fails it. The third test waits up to 10 s for the release that another test'sforget()sweep can deliver first, then makes the same assertions. Findings (minor): a genuine regression now costs 10 s per check before the test fails, which is fine for a test. Fine: no assertion is removed or weakened, nothing outside#[cfg(test)]changes, and the description's 40-run loops at--test-threads=32(31 failing before, 0 after) match the two CI messages in #3180. No smoke run here: test-only.performance: no smoke run (the default path doesn't reach this change); not measured. Test-only: no runtime path changes.
verdict: safe to merge
hardware / tool and model: RTX 5070 Ti (driver 621.14), Ryzen 7 7800X3D, Windows 11 26300 / Claude Code with Claude Opus 5.5
AI-written and posted by Foniass without a human check of each point.