X-Git-Url: https://git.ralfj.de/web.git/blobdiff_plain/1973dfdc8077795b3352f472feb2cd787685d87b..43307ef533738f9b108a6daa91541692f396a725:/personal/_posts/2022-07-02-miri.md diff --git a/personal/_posts/2022-07-02-miri.md b/personal/_posts/2022-07-02-miri.md index 1108e0d..41022f1 100644 --- a/personal/_posts/2022-07-02-miri.md +++ b/personal/_posts/2022-07-02-miri.md @@ -1,6 +1,7 @@ --- title: "The last two years in Miri" categories: rust +reddit: /rust/comments/vq3mmu/the_last_two_years_in_miri/ --- It has been [almost two years]({% post_url 2020-09-28-miri %}) since my last Miri status update. @@ -179,8 +180,9 @@ Miri is not *truly* random, but uses a pseudo-random number generator to make al This means you can explore various different possible choices by passing different *seeds* for Miri to use for its pseudo-random number generator. The following little shell snippet will run Miri with many different seeds, which is great to be able to locally reproduce a failure that you saw on CI, but that you are having trouble reproducing: ``` -for seed in $({ echo obase=16; seq 0 255; } | bc); do - MIRIFLAGS="-Zmiri-seed=$seed" cargo miri test || { echo "Failing seed: $seed"; break; }; +for SEED in $({ echo obase=16; seq 0 255; } | bc); do + echo "Trying seed: $SEED" + MIRIFLAGS=-Zmiri-seed=$SEED cargo miri test || { echo "Failing seed: $SEED"; break; }; done ``` It is important that you use exactly the same `MIRIFLAGS` as CI to ensure the failure can even happen! @@ -198,7 +200,7 @@ Passing all of these flags will make Miri's concurrency entirely deterministic. That can be useful to avoid non-deterministic test failures, but note that this will also mask many real-world bugs. Those test failures are often real, even if they can be hard to track down! -If you are still having trouble, feel free to come visit us in our [Zulip stram](https://rust-lang.zulipchat.com/#narrow/stream/269128-miri), which is the official communication channel for Miri. +If you are still having trouble, feel free to come visit us in our [Zulip stream](https://rust-lang.zulipchat.com/#narrow/stream/269128-miri), which is the official communication channel for Miri. By the way, if you are still disabling some tests on Miri because Miri used to not support panics/concurrency, it's time to give those tests another try. :) So this is a good opportunity to go over your `cfg(miri)` and similar attributes and re-evaluate if they are still needed. @@ -217,6 +219,8 @@ let limit = if cfg!(miri) { 10 } else { 10_000 }; If your test suite needs to access OS facilities such as timers or the file system, set `MIRIFLAGS=-Zmiri-disable-isolation` to enable those. (Miri will tell you when that is necessary.) If your test suite runs into an unsupported operation, please [report an issue](https://github.com/rust-lang/miri/issues). +However, note that we can only really support sufficiently "generic" operations -- like accessing file systems and network sockets. +To implement things like `Py_IsInitialized` would mean putting a Python interpreter into Miri; that is not going to happen. ;) If you want to add Miri to your CI to ensure your test suite keeps working in Miri, please consult our [README](https://github.com/rust-lang/miri/#running-miri-on-ci). That document is also a great starting point for any other questions you might have. @@ -224,7 +228,7 @@ That document is also a great starting point for any other questions you might h Miri is also integrated into the [Rust Playground](https://play.rust-lang.org/): you can select Miri in the "Tools" menu to check the code for Undefined Behavior. If Miri complains about your code and you do not understand why, we are happy to help! -The best place to ask for support is our [Zulip stram](https://rust-lang.zulipchat.com/#narrow/stream/269128-miri). +The best place to ask for support is our [Zulip stream](https://rust-lang.zulipchat.com/#narrow/stream/269128-miri). Questions are much easier to answer if you manage to reproduce the problem in a small self-contained bit of example code (ideally on the playground), but feel free to ask even if you do not know how to reduce the problem. ## Helping Miri