Skip to content

Commit 9e2afe9

Browse files
committed
README: update introduction
1 parent cf2df2d commit 9e2afe9

File tree

1 file changed

+24
-25
lines changed

1 file changed

+24
-25
lines changed

README.md

+24-25
Original file line numberDiff line numberDiff line change
@@ -1,39 +1,34 @@
11
# Miri
22

3-
An experimental interpreter for [Rust][rust]'s
4-
[mid-level intermediate representation][mir] (MIR). It can run binaries and
5-
test suites of cargo projects and detect certain classes of
6-
[undefined behavior](https://doc.rust-lang.org/reference/behavior-considered-undefined.html),
7-
for example:
3+
Miri is an [Undefined Behavior][reference-ub] detection tool for Rust. It can run binaries and test
4+
suites of cargo projects and detect unsafe code that fails to uphold its safety requirements. For
5+
instance:
86

97
* Out-of-bounds memory accesses and use-after-free
108
* Invalid use of uninitialized data
119
* Violation of intrinsic preconditions (an [`unreachable_unchecked`] being
1210
reached, calling [`copy_nonoverlapping`] with overlapping ranges, ...)
1311
* Not sufficiently aligned memory accesses and references
14-
* Violation of *some* basic type invariants (a `bool` that is not 0 or 1, for example,
12+
* Violation of basic type invariants (a `bool` that is not 0 or 1, for example,
1513
or an invalid enum discriminant)
1614
* **Experimental**: Violations of the [Stacked Borrows] rules governing aliasing
1715
for reference types
1816
* **Experimental**: Violations of the [Tree Borrows] aliasing rules, as an optional
1917
alternative to [Stacked Borrows]
20-
* **Experimental**: Data races
18+
* **Experimental**: Data races and emulation of weak memory effects, i.e.,
19+
atomic reads can return outdated values.
2120

2221
On top of that, Miri will also tell you about memory leaks: when there is memory
2322
still allocated at the end of the execution, and that memory is not reachable
2423
from a global `static`, Miri will raise an error.
2524

26-
Miri supports almost all Rust language features; in particular, unwinding and
27-
concurrency are properly supported (including some experimental emulation of
28-
weak memory effects, i.e., reads can return outdated values).
29-
3025
You can use Miri to emulate programs on other targets, e.g. to ensure that
3126
byte-level data manipulation works correctly both on little-endian and
3227
big-endian systems. See
3328
[cross-interpretation](#cross-interpretation-running-for-different-targets)
3429
below.
3530

36-
Miri has already discovered some [real-world bugs](#bugs-found-by-miri). If you
31+
Miri has already discovered many [real-world bugs](#bugs-found-by-miri). If you
3732
found a bug with Miri, we'd appreciate if you tell us and we'll add it to the
3833
list!
3934

@@ -45,33 +40,36 @@ clocks, are replaced by deterministic "fake" implementations. Set
4540
(In particular, the "fake" system RNG APIs make Miri **not suited for
4641
cryptographic use**! Do not generate keys using Miri.)
4742

48-
All that said, be aware that Miri will **not catch all cases of undefined
49-
behavior** in your program, and cannot run all programs:
43+
All that said, be aware that Miri does **not catch every violation of the Rust
44+
specification** in your program, not least because there is no such specification.
45+
Miri uses its own approximation of what is and is not Undefined Behavior in Rust.
46+
To the best of our knowledge, all Undefined Behavior that has the potential to
47+
affect a program's correctness *is* being detected by Miri, but you should consult
48+
[the Reference][reference-ub] for the official definition of Undefined Behavior.
49+
Miri will be updated with the Rust compiler to protect against UB as it is understood by the
50+
current compiler, but it makes no promises about future versions of rustc.
5051

51-
* There are still plenty of open questions around the basic invariants for some
52-
types and when these invariants even have to hold. Miri tries to avoid false
53-
positives here, so if your program runs fine in Miri right now that is by no
54-
means a guarantee that it is UB-free when these questions get answered.
52+
Further caveats that Miri users should be aware of:
5553

56-
In particular, Miri does not check that references point to valid data.
5754
* If the program relies on unspecified details of how data is laid out, it will
5855
still run fine in Miri -- but might break (including causing UB) on different
59-
compiler versions or different platforms.
56+
compiler versions or different platforms. (You can use `-Zrandomize-layout`
57+
to detect some of these cases.)
6058
* Program execution is non-deterministic when it depends, for example, on where
6159
exactly in memory allocations end up, or on the exact interleaving of
6260
concurrent threads. Miri tests one of many possible executions of your
63-
program. You can alleviate this to some extent by running Miri with different
64-
values for `-Zmiri-seed`, but that will still by far not explore all possible
65-
executions.
61+
program, but it will miss bugs that only occur in a different possible execution.
62+
You can alleviate this to some extent by running Miri with different
63+
values for `-Zmiri-seed`, but that will still by far not explore all possible executions.
6664
* Miri runs the program as a platform-independent interpreter, so the program
6765
has no access to most platform-specific APIs or FFI. A few APIs have been
6866
implemented (such as printing to stdout, accessing environment variables, and
6967
basic file system access) but most have not: for example, Miri currently does
7068
not support networking. System API support varies between targets; if you run
7169
on Windows it is a good idea to use `--target x86_64-unknown-linux-gnu` to get
7270
better support.
73-
* Weak memory emulation may [produce weak behaviours](https://github.com/rust-lang/miri/issues/2301)
74-
unobservable by compiled programs running on real hardware when `SeqCst` fences are used, and it
71+
* Weak memory emulation may [produce weak behaviors](https://github.com/rust-lang/miri/issues/2301)
72+
when `SeqCst` fences are used that are not actually permitted by the Rust memory model, and it
7573
cannot produce all behaviors possibly observable on real hardware.
7674

7775
Moreover, Miri fundamentally cannot tell you whether your code is *sound*. [Soundness] is the property
@@ -87,6 +85,7 @@ coverage.
8785
[Stacked Borrows]: https://github.com/rust-lang/unsafe-code-guidelines/blob/master/wip/stacked-borrows.md
8886
[Tree Borrows]: https://perso.crans.org/vanille/treebor/
8987
[Soundness]: https://rust-lang.github.io/unsafe-code-guidelines/glossary.html#soundness-of-code--of-a-library
88+
[reference-ub]: https://doc.rust-lang.org/reference/behavior-considered-undefined.html
9089

9190

9291
## Using Miri

0 commit comments

Comments
 (0)