Tests: XMA voice tests no longer race on the shared decode counters #3551
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/3551"
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 BBareth on 2026-11-30T23:06:07Z.
xma2_source_voice_decodes_and_manages_lifetimefails now and then in whole-suite runs (xaudio2.rs:1793, left 2, right 1). It reads the process-wide XMA decode counters before and after its own two submits and expects each to have moved by one.xma_voice_keeps_the_decoders_ten_channelssubmits an undecodable XMA2 buffer of its own, which moves the same error counter, and the two tests run at the same time. Both now hold one test-only lock. No runtime code changes.What is in it
crates/xcl/src/hle/xaudio2.rs(mod testsonly): aXMA_COUNTERSlock held by the two tests that submit buffers to an XMA voice.Tested
cargo build --workspace, thencargo test --workspace --no-fail-fast -- --test-threads=4on950b183a(on main86e86fcb): 2889 passed, 0 failed, 51 ignored.SKIPPEDon this adapter: 28: 22no wave64; 2no heap windows; 2no d3d12SDKLayers.dll; 1no D3D12 debug layer; 1 cannot disable the driver cache (no Developer Mode).cargo test -p xcl --lib xaudio2 -- --test-threads=4, repeated: 100 of 100 runs with 15 passed on this commit. Without the lock the failure showed in 1 of 2 whole-suite runs and 3 of 46 of these runs on the branch of #3549 (which does not touch this file), and in 0 of 43 on mainff0c364bwith the same source: it depends on timing, so the 100 clean runs do not prove the fix by themselves; the cause above was read from the two tests.Regression run
The diff is test-only, but it is in a runtime file, so both blocks are here.
A second round on the same builds: main 3074 frames, peak 30565 MB, device removals 0, crashes 0; this PR 3048 frames, peak 30649 MB, device removals 0, crashes 0. The A button is pressed once at 70 s.
Not tested
AI use
🤖 Generated with Claude Code
Imported from ivall/xcl. Originally posted by Foniass on 2026-12-01T07:58:12Z.
merge-check
base:
7d86c5d2b7head:
950b183aaemerge: clean
build: cargo build --workspace -> ok
tests: cargo test --workspace --no-fail-fast -- --test-threads=4 -> 2896 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 (xaudio2.rs, +6, all inside
#[cfg(test)] mod tests). No findings. The race is real:XMA_BUFFERS_DECODED/XMA_DECODE_ERRORSare process-wide,xma2_source_voice_decodes_and_manages_lifetimecompares them before and after its submits (~1798-1799), andxma_voice_keeps_the_decoders_ten_channelssubmits an undecodable buffer that moves the error counter at the same time. The fix holds a staticXMA_COUNTERSmutex (~1341) for the whole of both tests (~1406, ~1692), ignoring lock poisoning, and no assertion changed. The counters only move insidesubmit_decoded_buffer, synchronously in the submit call; no other lib test submits to an XMA voice, andacphalmoves the separatePCM_*counters, so the comparison can no longer see another test's submits. No smoke run here: test-only.performance: no smoke run (the default path doesn't reach this change); not measured.
verdict: safe to merge (test-only)
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.
Imported from ivall/xcl. Originally posted by Foniass on 2026-12-01T10:12:58Z.
Triage (#1607) – head
950b183No open or merged PR makes the same change. #1219 adds its own
XMA_TEST_LOCKfor its new test andxma2_source_voice_decodes_and_manages_lifetime, but not forxma_voice_keeps_the_decoders_ten_channels. If both land, they should share one lock.No problems found in the diff. The only tests that submit to an XMA voice (and so move
XMA_BUFFERS_DECODED/XMA_DECODE_ERRORS) are the two now holdingXMA_COUNTERS.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 fromthemoonx on 2026-12-01T16:40:04Z.
merge-check
base:
6bfb5c5153head:
950b183aaemerge: clean
build: cargo build --workspace -> ok
tests: cargo test --workspace --no-fail-fast -- --test-threads=4 -> 2904 passed, 0 failed, 51 ignored (base: 2904 passed, 0 failed, 51 ignored); SKIPPED: 25 (22 no wave64, 2 no heap windows, 1 no GPU_UPLOAD heaps), the same set as base; failing: none
review: read the whole diff (
xaudio2.rs, +6, all inmod tests). No findings.XMA_BUFFERS_DECODED/XMA_DECODE_ERRORS.decoded_voice_reports_no_bytes_required_to_the_titlebuilds an XMA decoder but submits nothing.6bfb5c5failedxma2_source_voice_decodes_and_manages_lifetime(xaudio2.rs:1793, left 2, right 1) in 1 of 3 runs today.hle::xaudio2::tests::at--test-threads=8, 40 runs each: main 40 of 40 ok, merge 40 of 40 ok.hle::xaudio2::tests::xmatests at--test-threads=2, 200 runs each: 200 of 200 ok on both.before_errors, on both trees, and ran the threexmatests at--test-threads=3, 10 runs each.left: 2,right: 1atxaudio2.rs:1793.performance: none: test code only.
verdict: safe to merge
hardware / tool and model: RTX 3060 12 GB (610.88), Ryzen 7 5700X, Windows 11 Pro 26300 / Claude Code (Claude Opus 5.5)
Imported from ivall/xcl. Originally posted by bmjask on 2026-12-02T14:11:20Z.
@Prime1997 could you take a look at this one for review and merge? My automated review notes are above, if any.