futures-timer icon indicating copy to clipboard operation
futures-timer copied to clipboard

Running `cargo miri test` fails due to thread outliving main thread

Open StoicDeveloper opened this issue 10 months ago • 0 comments

With the minimal example:

#[cfg(test)]
pub mod tests {
  
    #[test]
    fn mf_test_delay() {
        block_on(Delay::new(Duration::from_millis(500)));
    }
}

running the command:

MIRIFLAGS="-Zmiri-disable-isolation" cargo miri test mf_  

will cause the tests to pass, but the overall command will fail with the following output:

❯ MIRIFLAGS="-Zmiri-disable-isolation" cargo miri test mf_
    Finished `test` profile [unoptimized + debuginfo] target(s) in 0.16s
     Running unittests src/lib.rs (<location>)

running 1 tests
test stream::futures_unordered::mapped_futures::tests::mf_test_delay ... ok

test result: ok. 1 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in 1.68s

error: the main thread terminated without waiting for all remaining threads

note: set `MIRIFLAGS=-Zmiri-ignore-leaks` to disable this check

error: aborting due to 1 previous error

error: test failed, to rerun pass `--lib`

Rust version: ❯ rustc --version rustc 1.85.0-nightly (0aeaa5eb2 2024-12-14)

StoicDeveloper avatar Apr 04 '25 22:04 StoicDeveloper