HLE/dsp: use atomic Status fields and release ordering without &mut aliasing #483
No reviewers
Labels
No labels
accessibility
bug
documentation
duplicate
enhancement
good first issue
help wanted
invalid
question
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/fxceless--victory-fork!483
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-483"
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?
@AscilCH on GitHub · 2026-11-25 01:23 UTC · original
AscilCH:fix/hle-dsp-atomic-status-no-mut-aliasing→main· +130 −21 · 1 files · 1 commits · openProblem
In
crates/victory-hle/src/modules/dsp.rs:Status:XDspActivatehands the title a*const Statuspointer (status.write(&*new.status)) that title audio/worker threads poll asynchronously.XDspSubmitCommandcreated exclusive references&mut *streamand&mut *stream.statuswhile title threads could concurrently read*status, causing Rust aliasing UB even withwrite_volatile.XDspSubmitCommandreadstatus.submittednon-atomically and wrotesubmitted/result/completedviawrite_volatile(which does not provide inter-thread memory ordering over the precedingwrite_bytes(command.output, 0, samples)and can lose or regress tickets under concurrent submissions).Fix
#[repr(C)] Statusfields toAtomicU32/AtomicI32with compile-time layout assertions (size_of::<Status>() == 16,align_of::<Status>() == 4).&*streaminXDspSubmitCommand, serialize ticket increments and status updates under a per-streamMutex<()>, and publishcompletedwithOrdering::Releaseafter zeroingcommand.outputand storingsubmitted/result.concurrent_submissions_and_polling_are_monotonic_and_atomic.Verification
cargo test -p victory-hle --locked dsp::tests: 2 passed, 0 failedcargo xtask policy: 169 files okcargo clippy -p victory-hle --all-targets --locked -- -D warnings: cleancargo clippy -p victory-hle --all-targets --all-features --locked -- -D warnings: clean(AI-assisted; synthetic unit tests only, no game data.)
View command line instructions
Checkout
From your project repository, check out a new branch and test the changes.Merge
Merge the changes and update on Forgejo.