tokio-rs / loom

Concurrency permutation testing tool for Rust.
MIT License
2.14k stars 111 forks source link

Assert in Notify triggered via `JoinHandle.join()` #177

Open bdonlan opened 4 years ago

bdonlan commented 4 years ago

CI on this branch on tokio https://github.com/tokio-rs/tokio/pull/2914 is triggering an assert deep in loom's Notify::wait() function. It can be reliably reproduced by running on that branch:

 (cd tokio; RUST_BACKTRACE=1 RUSTFLAGS='--cfg loom --cfg tokio_unstable -Dwarnings' LOOM_MAX_PREEMPTIONS=2 cargo test --lib --release --features full -- --nocapture pool_shutdown)

Based on initial investigation, it seems that branch_thread selects a non-runnable thread for execution, possibly because the scheduler's execution path is inconsistent with the actual state of the threads in question.

bdonlan commented 4 years ago

Found the cause. There was nondeterminism, in the form of the JoinHandles coming out of a HashMap (where keys are of indeterminate order).