Repository navigation
XAudio2: GetState keeps the title's context for a buffer that just ended - #2410
treybertram06 wants to merge 1 commit into
Conversation
6641bd5 to
adf3f63
Compare
|
Verification on RTX 3060 Ti (Windows 11), branch merged with current
The lowered program is missing an expected group barrier (or emits one where none is expected). Needs a fix before merge. — Devin |
Tested
Not tested
AI use
|
…#2414, xcl-dev#2415 Integrates per-draw mirror sync fast path (xcl-dev#2437), PresentX compositor hardening (xcl-dev#2418), XAudio2 GetState buffer context fix (xcl-dev#2410), and Wine test fixes (xcl-dev#2414, xcl-dev#2415). Assisted-by: Antigravity (Gemini 4 Neon)
|
Thanks for running it. That failure isn't from this PR. On
The diff only touches (Checked and written with Claude Code, Claude Opus 5.5.) |
|
Test report from Linux + Wine on AMD: this change does not fix #2386 on this lane, and the assertion it targets is reproducible here exactly. Prepared with AI assistance: DeepSeek V4.1 Flash in OpenCode; the commands were run by it and the output is pasted verbatim. Setup
Result
The new test passes ( Base, Same assertion on this PR (line 1626 after the added code), same values: The e2e test title shows the same thing, on base and on this PR alike: (its other Not tested
AI use
|
adf3f63 to
ae0019c
Compare
|
Thanks, that's useful, but it's a different problem from #2386. The failing test, (Claude Code, Claude Opus 5.5.) |
…#2414, xcl-dev#2415 Integrates per-draw mirror sync fast path (xcl-dev#2437), PresentX compositor hardening (xcl-dev#2418), XAudio2 GetState buffer context fix (xcl-dev#2410), and Wine test fixes (xcl-dev#2414, xcl-dev#2415). Assisted-by: Antigravity (Gemini 4 Neon)
bmjask
left a comment
There was a problem hiding this comment.
P1 ABA bug: end_buffer removes and drops Box while ended retains only (token, orig_context). An in-flight GetState can read A token, audio thread drops A and invokes title callback, callback submits B whose allocation reuses A address, then the hook resolves stale A token through live_buffers and returns B context. Keep ended DecodedBuffers/token reservations alive through eviction and add a forced-address-reuse race test. The fixed 64-entry retention also means sufficiently delayed lookup loses the mapping.
A decoded (XMA / Opus) voice submits each buffer with XCL's own token as the context and maps it back to the title's in GetState. When the buffer ends between XAudio2's GetState and XCL's lookup, OnBufferEnd has already taken the token out of live_buffers, and the title got the token, the address of a freed DecodedBuffer, as pCurrentBufferContext (xcl-dev#2386). Each voice now keeps its last 64 ended buffers, their PCM freed; the end of a buffer moves it there under the live_buffers lock, so a lookup finds the token in one of the two. Keeping the allocation, not only its address, holds the token: a buffer submitted after it cannot get the same address while a stale GetState token can still name it (the ABA race in review). A context XCL never made (a buffer the title queued itself) still passes through unchanged: clearing it on a miss, as the issue suggests, would drop those. The tests fail without the ended buffers (the token comes back) and without holding their allocation. Fixes xcl-dev#2386 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
ae0019c to
4767b1a
Compare
|
@bmjask Thanks, that's right. Fixed in
Tested on
(Claude Code, Claude Opus 5.5.) |
|
Re-verification on RTX 3060 Ti (Windows 11), new head merged with current
Thanks! — Devin |
On a decoded (XMA / Opus) source voice, XCL submits each buffer with its own token as the context and maps it back to the title's context in
GetState. If the buffer ends between XAudio2'sGetStateand XCL's lookup,OnBufferEndhas already removed the token fromlive_buffers. The title then gets the token, which is the address of a freedDecodedBuffer, aspCurrentBufferContext. Fixes #2386.Each voice now keeps its last 64 ended tokens together with the title's context.
OnBufferEndrecords a token under thelive_bufferslock, so a lookup always finds the token in one of the two. The issue suggests clearing the context to null on a miss. That would also clear the context of a buffer the title queued itself, which XCL never wraps, so a context XCL didn't make still passes through unchanged.What is in it
crates/xcl/src/hle/xaudio2.rs:end_bufferandtitle_context(live tokens, then recently ended ones), used bydecoded_cb_buffer_endandget_state;endedring. It holds each ended buffer's allocation, with its PCM freed, so a later buffer can't get the address of a token that's still kept (the ABA race from review);get_state_context_survives_buffer_end, which fails without the ring because the token comes back, andended_token_is_not_reused_by_a_later_buffer, which fails when the ring keeps only the address.Tested
cargo test -p xcl --lib xaudio2: 11 passed, 0 failed. Each new test fails without the part of the change it covers.cargo test --workspace --no-fail-fast -- --test-threads=4(XCL_DXC_DIRset to DXC 1.9), on the branch rebased ontomaine0d93c84: 1423 passed, 0 failed, 46 ignored.a_bridged_mask_write_where_one_half_is_elsewhere_meets_no_barrierfailure wasmain's; Tests: check divergent block barriers in a_bridged_mask_write #2420 fixed it.SKIPPED:no wave64;no heap windows;Regression run
The title used here decodes its audio through XAPU, so these runs do not reach the changed code (see Not tested).
Not tested
GetStateon an XMA / Opus voice while its buffers end, and the title in the regression run uses the XAPU path. The unit test covers the lookup afterOnBufferEnd, not XAudio2's own threads.AI use