tokio-rs / loom

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

support lazy_static access during drop #179

Open hawkw opened 4 years ago

hawkw commented 4 years ago

I'm testing some code using loom, which (among other things) accesses a lazy_static value in a Drop impl. It appears that loom's simulated lazy_static...doesn't like this:

thread 'main' panicked at 'attempted to access lazy_static during shutdown', /home/eliza/.cargo/registry/src/github.com-1ecc6299db9ec823/loom-0.3.6/src/rt/lazy_static.rs:45:14

It would be nice if this could be supported. IIRC, I think loom's thread-locals have a similar issue, but I might be misremembering.

Is it possible to, for example, ensure that the lazy_static's execution state is dropped after any values constructed during the test that might touch it?

hawkw commented 4 years ago

In this particular case, it's somewhat important that loom's lazy static be used in the test, as using a "real" lazy static results in non-deterministic behavior, hitting an internal loom assertion elsewhere.