Skip to content

Add Miri to more crates - #10507

Merged
Jefffrey merged 5 commits into
apache:mainfrom
ethantang93:issue-10471-add-miri-to-more-crates
Aug 6, 2026
Merged

Add Miri to more crates#10507
Jefffrey merged 5 commits into
apache:mainfrom
ethantang93:issue-10471-add-miri-to-more-crates

Conversation

@ethantang93

Copy link
Copy Markdown
Contributor

Which issue does this PR close?

closes #10471

Rationale for this change

The Miri workflow currently covers only a subset of packages. This adds more miri coverage to detect unsafe code, Parquet crate remains excluded because it is tracked separately in #614.

What changes are included in this PR?

  • Adds Miri testing for arrow, arrow-avro, arrow-cast, arrow-csv, arrow-ipc, arrow-json, arrow-row, arrow-select, and arrow-string.
  • Updates the gh action workflow path filters in miri.yaml, some crates were missing before
  • adds ignore to tests that takes too long to run
  • adds ignore to tests that were failing due to inline assembly
  • Sets INSTA_WORKSPACE_ROOT to prevent snapshot tests from invoking unsupported subprocess operations under Miri

note: it takes about 50mins to run miri on my M3 laptop. when this pr gets merge i think it's expected to prolong the CI time in the miri workflow, but we can always add more parallel workers

Are these changes tested?

i ran the following to test locally.

  • rustup run nightly bash .github/workflows/miri.sh (runs the whole miri suite)
  • cargo test
  • cargo clippy --workspace --all-targets --all-features -- -D warnings
  • git diff --check

Are there any user-facing changes?

no, only tests

AI disclosure

I used codex to draft this pr after i got the project and miri tests running on my laptop. I have reviewed all the code and have built, tested these changes. I am happy to own follow-ups too.

@Jo2234 Jo2234 left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

The expanded crate coverage looks useful. One workflow-trigger gap: could we also include the workspace Cargo.toml and Cargo.lock in the pull_request.paths filter? A root dependency, feature, or resolver change can alter the code built for all of these crates without touching any listed crate directory, so this Miri job would otherwise be skipped for a change that materially affects its test matrix.

@ethantang93

Copy link
Copy Markdown
Contributor Author

thanks ! fair point, will add this in

@ethantang93
ethantang93 force-pushed the issue-10471-add-miri-to-more-crates branch from 9e2af8c to 3b884d3 Compare August 3, 2026 17:58
@ethantang93
ethantang93 marked this pull request as ready for review August 4, 2026 03:22
Comment thread arrow-array/src/array/boolean_array.rs Outdated
}

#[test]
#[cfg_attr(miri, ignore)]

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

could we add comments for each ignore to indicate if its due to slowness, unsupported by miri, etc.?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

good idea

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

done, now every ignore has a reason

Comment thread arrow-ipc/src/reader.rs
let data = ArrayData::builder(data_type)
.len(len)
.add_buffer(Buffer::from(vec![0_u8; len * width]))
.add_buffer(Buffer::from(MutableBuffer::from_len_zeroed(len * width)))

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

is there some miri issue here being fixed?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

yeah i think this is one issue miri found, was getting an error "Misaligned buffers[0] in array of type Int32, offset from expected alignment of 4 by 2"
based on my (limited) understanding vec![0_u8; len * width] only guarantees 1 byte alignment, so it can be misaligned for wider primitives.

Comment thread arrow-ipc/src/writer.rs
let out: Vec<u8> = writer.into_inner().unwrap();

let buffer = Buffer::from_vec(out);
let buffer = Buffer::from_slice_ref(out);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

same with these, is there some issue with miri?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

i think this is essentially same issue as above, vec<u8> has byte alignment, but the test later runs zero copy read with require_alignment(true) , so miri reports the buffer as misaligned.

@Jefffrey

Jefffrey commented Aug 4, 2026

Copy link
Copy Markdown
Contributor

looks like miri went from around 20min to a bit over 30min; probably fine for now, can experiment with more partitions in a followup

@ethantang93
ethantang93 force-pushed the issue-10471-add-miri-to-more-crates branch from 1e7cde5 to 078a9eb Compare August 4, 2026 21:50

@Jefffrey Jefffrey left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

thanks for the test fixes; they make sense, and since they were caught by existing error handling code (i.e. didnt panic internally) i think it was just an issue with how the tests were written and not a deeper bug in the library 🤔

@ethantang93
ethantang93 force-pushed the issue-10471-add-miri-to-more-crates branch from 2240b61 to 75641ab Compare August 5, 2026 17:02
@ethantang93

Copy link
Copy Markdown
Contributor Author

@Jefffrey yeah agreed. btw, i just did a force push to resolve a conflict.

@Jefffrey Jefffrey added the development-process Related to development process of arrow-rs label Aug 6, 2026
@Jefffrey
Jefffrey merged commit 64aaccf into apache:main Aug 6, 2026
40 checks passed
@Jefffrey

Jefffrey commented Aug 6, 2026

Copy link
Copy Markdown
Contributor

thanks @ethantang93 & @Jo2234

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Run miri against more crates

3 participants