tokio-rs / loom

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

Panic occurs when access `lazy_static!` at the end of thread #152

Open quininer opened 4 years ago

quininer commented 4 years ago
loom::lazy_static!{
    static ref ID: usize = 0x42;
}

loom::thread_local!{
    static BAR: Bar = Bar;
}

struct Bar;

impl Drop for Bar {
    fn drop(&mut self) {
        let _ = &*ID;
    }
}

fn main() {
    loom::model(|| {
        BAR.with(|_| ());
    });
}

output:

thread 'main' panicked at 'attempted to access lazy_static during shutdown', /loom-0.3.4/src/rt/lazy_static.rs:43:9

Maybe we should be ensured that drop of lazy_static! occurs after thread_local!.