fix example
[web.git] / ralf / _posts / 2019-03-26-miri-as-rustup-component.md
1 ---
2 title: "Miri available as rustup component"
3 categories: rust
4 reddit: /rust/comments/b5um0v/miri_available_as_rustup_component/
5 ---
6
7 Running your unsafe code test suite in Miri has just gotten even easier: Miri is now available as a `rustup` component!
8 Huge thanks to @oli-obk and @mati865 who made this happen.
9
10 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.
11 However, Miri cannot execute all programs, and it also cannot detect all forms of misbehavior.
12 For further information, please check out [Miri's README](https://github.com/rust-lang/miri#readme).
13
14 <!-- MORE -->
15
16 Installation (only on nightly toolchains) is now as simple as
17 ```
18 rustup component add miri
19 ```
20 After installing Miri, you can run your crate's test suite in it with `cargo miri test`.
21 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.
22 If you have `#[should_panic]` tests, try `cargo miri test -- -- -Zunstable-options --exclude-should-panic` because Miri currently aborts execution on a panic.
23
24 There's a lot of work left to be done, in particular to enable more programs to execute in Miri.
25 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.
26 I cannot express how glad it makes me to be able to contribute to the Rust ecosystem becoming a bit safer.
27
28 Maybe your crate is next?