Repository navigation
Conversation
…fixes #839) A f32 slice over the title's output pointer is undefined behaviour when the pointer is not 4-byte aligned, and aborts with debug assertions. Build the frames in our own buffer and copy them as bytes. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
DenRakEiw
left a comment
There was a problem hiding this comment.
Tested head 5075e1e (fast-forward on main ffe310e) on Windows 11 x64 (Rust 1.98.1 MSVC):
cargo test -p victory-hle: 95 passed, 0 failed (plusno_dll_planting: 1 passed), includingmodules::apu::tests::decodes_into_an_unaligned_buffercargo clippy -p victory-hle --all-targets: 0 warningscargo xtask policy: ok
Clean UB fix writing decoded PCM as bytes to potentially unaligned caller buffers (fixes #839). Approving.
AI-assisted (Gemini 4 Neon).
|
Independent Linux/Wine validation of Full workspace unit/integration suite, all features, all 14 generated Windows MSVC test executables: 342 passed, 5 failed, 6 ignored. Matched baseline: 341 passed, 5 failed, 6 ignored. The five failures are unchanged: empty pipeline library (#347), missing Wine Winsock export (#217), checksum-rejection expectation, nested Cargo fixture build, and Windows xtask attempting to launch host Git. Both Windows-target workspace Clippy configurations (all targets, with and without all features, Rust 1.98.1, Wine 11.22, RTX 5090 / NVIDIA 620.73.04, vkd3d-proton |
What
processbuilds the decoded frames (interleaved, or deinterleaved for stereo) in a buffer of its own and copies them to the title's output buffer as bytes, instead of making an&mut [f32]over the title's pointer.Why
The output pointer comes from the title and need not be 4-byte aligned.
slice::from_raw_parts_muton an unaligned*mut f32is undefined behaviour; with debug assertions (dev builds, tests) it aborts the process. On x86-64 release builds the unaligned stores happened to work.Test
decodes_into_an_unaligned_buffer: a 20 ms stereo Opus packet decoded into buffers at byte offsets 1, 2 and 3 gives the same bytes as at offset 0, interleaved and deinterleaved. Before this change it aborts: "slice::from_raw_parts_mut requires the pointer to be aligned".cargo clippy --workspace --all-targets [--all-features] --locked -- -D warningsandcargo test --workspace --lockedpass.🤖 Generated with Claude Code