rust-lang / packed_simd

Portable Packed SIMD Vectors for Rust standard library
https://rust-lang.github.io/packed_simd/packed_simd_2/
Apache License 2.0
589 stars 74 forks source link

Fix undefined behavior reported by miri when reading or writing slices #351

Closed jhorstmann closed 1 year ago

jhorstmann commented 1 year ago

Many methods in the slice or array api take a pointer to the first element and then use that pointer to read or write multiple lanes.

This is undefined behavior according to miri since pointer is only valid for a single element. The fix is to use the as_ptr/as_mut_ptr methods of the slice, which gives a pointer to the whole slice and also leads to nicer code.

jhorstmann commented 1 year ago

It's not yet possible to run the whole testsuite with miri as the code also uses many llvm or platform intrinsics, which are not supported. All tests that include slice or array in their name now pass, which is a big improvement.

This also enables successfully running the arrow-rs tests with its simd feature under miri.

workingjubilee commented 1 year ago

This CI really needs to be ported from Travis to GHA.

jhorstmann commented 1 year ago

This CI really needs to be ported from Travis to GHA.

I can look into that. Very early version in my fork

workingjubilee commented 1 year ago

Great!