Current NEON vld3* loading implementation inserts an alignment requirement where none is required.
Consider following code:
use std::arch::aarch64::*;
use std::mem::MaybeUninit;
fn main() {
let data: Vec<u8> = vec![0u8; 200];
let base = data.as_ptr() as usize;
let misaligned_offset = if base % 16 == 0 { 2 } else { 0 };
let ptr = unsafe {
data.as_ptr().add(misaligned_offset) as *const f32
};
unsafe {
type W = [f32; 16];
let mut mem = MaybeUninit::<W>::uninit();
std::ptr::copy_nonoverlapping(
ptr,
mem.as_mut_ptr().cast::<f32>(),
12,
);
let _ = mem.assume_init();
}
println!("we're done");
}
Since copy_nonoverlapping requires both pointers to be aligned to at least align_of::<f32>(), passing a pointer that is not sufficiently aligned is an UB. I have not checked the release build, but this is immediately detected by the fuzzer
Current NEON
vld3*loading implementation inserts an alignment requirement where none is required.Consider following code:
Since
copy_nonoverlappingrequires both pointers to be aligned to at leastalign_of::<f32>(), passing a pointer that is not sufficiently aligned is an UB. I have not checked the release build, but this is immediately detected by the fuzzer