Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Merged

Conversation

jhorstmann
Copy link
Contributor

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.

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
Copy link
Contributor Author

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.

@@ -61,6 +61,7 @@ macro_rules! impl_from_array {
mod [<$id _from>] {
use super::*;
#[test]
#[cfg_attr(miri, ignore)]
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This test itself does something weird and I don't have a good idea what the intention here was. I'm open to re-enabling it, the benefit of ignoring it is that cargo miri test -- array fully passes.

@workingjubilee
Copy link
Contributor

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

@jhorstmann
Copy link
Contributor Author

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

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

@workingjubilee
Copy link
Contributor

Great!

@workingjubilee workingjubilee merged commit 4d4d27a into rust-lang:master Jul 28, 2023
69 of 99 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants