XAudio2: GetState race leaks freed internal DecodedBuffer pointer in pCurrentBufferContext #2386
Labels
No labels
accessibility
bug
documentation
duplicate
enhancement
goal:world-load
good first issue
help wanted
invalid
keep-open
off-goal
question
stale
test-only
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/xcl-dev--xcl#2386
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
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?
@ahmetbagci8 on GitHub · 2026-11-25 17:39 UTC · original
Summary
In
crates/xcl/src/hle/xaudio2.rs,submit_decoded_buffersubmits each decoded buffer with the internalBox<DecodedBuffer>heap address (token) asXAUDIO2_BUFFER::pContextand stores it invoice_state.live_buffers.When the title calls
IXAudio2SourceVoice::GetState(get_state, lines 1138-1157):If XAudio2's audio thread completes that buffer and runs
decoded_cb_buffer_end(lines 611-617, which removestokenfromlive_buffersand drops theBox<DecodedBuffer>) betweenorig(this, state_out, flags)andvoice_state.live_buffers.lock(), thenlive_buffers.get(&cur)returnsNone.get_stateleaves(*state_out).current_buffer_contextset to the freed internalDecodedBufferpointer instead of the title'sorig_contextor null, causing a use-after-free / type-confusion crash if the title dereferencespCurrentBufferContext.Suggested fix
Clear
current_buffer_contextto null when the token is no longer inlive_buffers(or look it up in a small recently-ended ring):Not tested
082944135cd2b96288470a595861fa608eee08dcwithout a new runtime test.AI use
xaudio2.rsand drafted this report; the author reviewed it before posting.@oni-swr on GitHub · 2026-11-25 18:04 UTC · original
Claiming #2386: fixing the
IXAudio2SourceVoice::GetStaterace onpCurrentBufferContext(crates/xcl/src/hle/xaudio2.rs) with a deterministic failing-first CPU unit test, then queuing the paired RX 7800 XT smoke run before opening the PR.AI use: Claude Code (Claude Sonnet 5.5) will implement, test, and draft the PR.
@oni-swr on GitHub · 2026-11-25 18:21 UTC · original
Releasing claim on #2386 — competing PR #2410 already implements this fix with a unit test and paired smoke run.
AI use: orchestrated via Antigravity / Claude Sonnet 5.5.