miri
miri copied to clipboard
Implement "many-seeds" mode directly in the driver?
Currently, ./miri run and cargo miri both have an independent implementation of "many-seeds" mode. The one in ./miri is concurrent, the one in cargo miri is not.
I wonder if we could avoid all that duplication by having this implemented directly in the driver instead, via something like -Zmiri-many-seeds? I can imagine two possible implementations:
- Inside a single rustc driver session, we can spin up more than one interpreter instance -- all the relevant state is (should be) in the interpreter instance, so this will give us clean independent executions. They could even share the query cache this way. However, this would AFAIK have to be sequential -- or can we make use of "parallel rustc" support for this somehow?
- Inside the
miribinary, create multiple rustc driver sessions, each in a separate thread. I think that should be possible? Or does the rustc driver infrastructure assume that it is instantiated only once per process?
Cc @bjorn3 since you know a lot about this driver stuff, IIRC. :) Cc @SparrowLii for parallel rustc know-how.
- I think that should be possible? Or does the rustc driver infrastructure assume that it is instantiated only once per process?
Possible, we only use tls, no true globals.
But I'd prefer just using parallel rust logic to run everything in parallel. Tho that may run into the various issues parallel rustc still has
Miri does have some static to avoid printing duplicate errors; those should be audited for whether they still make sense when we are running multiple times in the same process.
But I'd prefer just using parallel rust logic to run everything in parallel. Tho that may run into the various issues parallel rustc still has
Turns out this works just fine. :) See https://github.com/rust-lang/miri/pull/4105.