XAudio2: use saturating_mul for avg_bytes in pcm16_for_rate #1249
No reviewers
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!1249
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-1249"
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?
@b3IKK on GitHub · 2026-11-24 13:44 UTC · original
b3IKK:xaudio2/pcm16-rate-overflow→main· +11 −1 · 1 files · 1 commits · openpcm16_for_ratecomputedrate * block as u32without overflow checks. A malformed voice format with a large sample rate (e.g. 8 channels andrate >= 0x1000_0000) panicked in debug builds (aborting across theextern "system" fnboundary inCreateSourceVoice) and wrapped to a bogusavg_bytesin release builds.This switches
avg_bytestorate.saturating_mul(block as u32).What is in it
crates/xcl/src/hle/xaudio2.rs: userate.saturating_mul(block as u32)inpcm16_for_rate; add unit testpcm16_for_rate_saturates_avg_bytes_on_overflow(panicked on multiplication overflow before the fix).Tested
stable-x86_64-pc-windows-msvc), DXC 1.9.2609.5, debug (scripts/test.ps1) and release (scripts/smoke.ps1).\scripts\test.ps1(cargo build --workspace+cargo test --workspace -- --test-threads=4): 752 passed, 0 failed, 41 ignored (SKIPPED GPU tests: 2no wave64—gpu::recomp::tests::gpu_geometry_wave32_prefix_count_over_a_mask,gpu::recomp::tests::gpu_wave32_program_in_wave64_hardware)cargo test -p xcl --lib pcm16_for_rate_saturates_avg_bytes_on_overflow: 1 passed, 0 failed (panicked with multiplication overflow before the fix)Regression run
main:
PR:
Not tested
AI use
xaudio2.rs, wrote the fix and regression test, ran the test suite andscripts/smoke.ps1regression runs, and drafted this PR description.@DavidM1911 on GitHub · 2026-11-24 14:02 UTC · original
Verification on RTX 3060 Ti (Windows 11), branch merged with current
main:Thanks!
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.