From cd5cee841061db21942bf7fded226dfa5c42303e Mon Sep 17 00:00:00 2001 From: Ralf Jung Date: Tue, 26 Mar 2019 21:07:52 +0100 Subject: [PATCH] miri on rustup --- .../2019-03-26-miri-as-rustup-component.md | 27 +++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 personal/_posts/2019-03-26-miri-as-rustup-component.md diff --git a/personal/_posts/2019-03-26-miri-as-rustup-component.md b/personal/_posts/2019-03-26-miri-as-rustup-component.md new file mode 100644 index 0000000..a1ffe4f --- /dev/null +++ b/personal/_posts/2019-03-26-miri-as-rustup-component.md @@ -0,0 +1,27 @@ +--- +title: "Miri available as rustup component" +categories: rust +--- + +Running your unsafe code test suite in Miri has just gotten even easier: Miri is now available as a `rustup` component! +Huge thanks to @oli-obk and @mati865 who made this happen. + +Miri can run your test suite in a very slow, interpreted mode that enables it to test for undefined behavior: if an out-of-bounds array access happens, uninitialized memory gets used the wrong way or a dangling raw pointer gets dereferenced, Miri will notice and tell you. +However, Miri cannot execute all programs, and it also cannot detect all forms of misbehavior. +For further information, please check out [Miri's README](https://github.com/rust-lang/miri#readme). + + + +Installation (only on nightly toolchains) is now as simple as +``` +rustup component add miri +``` +After installing Miri, you can run your crate's test suite in it with `cargo miri test`. +I suggest you do `cargo clean` first because Miri needs to build its own standard library, and rustc can get confused when crates built with different standard libraries get mixed. +If you have `#[should_panic]` tests, try `cargo miri test -- -- -Zunstable-options --exclude-should-panic` because Miri currently aborts execution on a panic. + +There's a lot of work left to be done, in particular to enable more programs to execute in Miri. +Still, slowly but steadily, my [vision]({% post_url 2017-05-23-internship-starting %}) of Miri as a practical tool to test for undefined behavior is actually becoming reality: [the standard library](https://github.com/RalfJung/miri-test-libstd) and [hashbrown](https://github.com/Amanieu/hashbrown/) have their test suites running in Miri under CI. +I cannot express how glad it makes me to be able to contribute to the Rust ecosystem becoming a bit safer. + +Maybe your crate is next? -- 2.30.2