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

run Miri on CI #113

Merged
merged 2 commits into from
Mar 29, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ jobs:
- test
- simd
- msrv
- miri
steps:
- run: exit 0

Expand Down Expand Up @@ -127,3 +128,22 @@ jobs:
uses: actions-rs/cargo@v1
with:
command: build

miri:
name: Test with Miri
runs-on: ubuntu-latest

steps:
- name: Checkout
uses: actions/checkout@v1

- name: Install Rust
uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: nightly
components: miri
override: true

- name: Test
run: MIRIFLAGS="-Zmiri-tag-raw-pointers -Zmiri-check-number-validity" cargo miri test
Copy link
Owner

Choose a reason for hiding this comment

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

I assume you'll know best: what's the likelihood of these changing and causing our CI to fail?

Copy link
Contributor Author

@RalfJung RalfJung Mar 28, 2022

Choose a reason for hiding this comment

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

These flags basically put Miri into "hard mode", adding some extra checks that are off-by-default but give extra confidence in the unsafe code. I'm not sure what kind of unsafe code httparse uses or which kind of code you plan to use in the future, so I cannot really give failure probabilities for the UB checks.

When we change flags we usually first just deprecate them (showing a warning) because we know removing them would break CI. Even this happens rarely. The last actual breaking change wrt our flags was rust-lang/miri#1769; back then I made an effort to send PRs or at least "heads-up" issues to all projects I could find that used Miri on CI to fix them preemptively. I don't even remember the last breaking flag change before that...

Copy link
Owner

Choose a reason for hiding this comment

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

Sounds good to me, thanks!

4 changes: 4 additions & 0 deletions build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,10 @@ fn enable_simd(/*version: Version*/) {
println!("cargo:warning=building for no_std disables httparse SIMD");
return;
}
if env::var_os("CARGO_CFG_MIRI").is_some() {
println!("cargo:warning=building for Miri disables httparse SIMD");
return;
}

let env_disable = "CARGO_CFG_HTTPARSE_DISABLE_SIMD";
if var_is(env_disable, "1") {
Expand Down