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

Enable running arrow-array and arrow-arith with miri and avoid strict provenance warning #5387

Merged
merged 4 commits into from
Feb 18, 2024

Conversation

jhorstmann
Copy link
Contributor

Which issue does this PR close?

Noticed this while looking into #614, fixes for parquet crate will be done in a separate PR.

Rationale for this change

What changes are included in this PR?

  • big integer division can simply use the fallback logic when running with miri
  • since miri implies a nightly rust version, we can use the unstable strict-provenance feature and avoid a warning when creating buffers with zero capacity

Are there any user-facing changes?

@github-actions github-actions bot added the arrow Changes to the arrow crate label Feb 11, 2024
Copy link
Contributor

@Jefffrey Jefffrey left a comment

Choose a reason for hiding this comment

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

Seems fine to me, though I confess I'm not too across the details of what's exactly happening here(but seems should only affect Miri anyway) 👍

@@ -202,7 +202,7 @@ fn div_rem_word(hi: u64, lo: u64, divisor: u64) -> (u64, u64) {
);
(quot, rem)
}
#[cfg(not(target_arch = "x86_64"))]
#[cfg(any(not(target_arch = "x86_64"), miri))]
Copy link
Contributor

Choose a reason for hiding this comment

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

Ah nice 👍

Didn't realize it was this simple change to get Miri working 👀

Comment on lines +483 to +491
#[cfg(miri)]
{
// Since miri implies a nightly rust version we can use the unstable strict_provenance feature
unsafe { NonNull::new_unchecked(std::ptr::invalid_mut(ALIGNMENT)) }
}
#[cfg(not(miri))]
{
unsafe { NonNull::new_unchecked(ALIGNMENT as *mut u8) }
}
Copy link
Contributor

Choose a reason for hiding this comment

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

I'm not as familiar with what's happening here, but I guess as long as it's gated so only affects Miri, should be alright?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

invalid_mut is basically doing the same thing as the cast below, but does not trigger a warning about integer to pointer casts. But it is behind a feature flag and only available on nightly rust.

If you want to go down the rabbit hole of what is pointer provenance, this would be a good point to start: https://github.com/RalfJung/rfcs/blob/provenance/text/0000-rust-has-provenance.md

@Jefffrey Jefffrey merged commit 2e6c7b9 into apache:master Feb 18, 2024
31 checks passed
@Jefffrey
Copy link
Contributor

Cheers 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
arrow Changes to the arrow crate
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants