loom icon indicating copy to clipboard operation
loom copied to clipboard

support lazy_static access during drop

Open hawkw opened this issue 5 years ago • 1 comments

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 avatar Oct 14 '20 23:10 hawkw

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.

hawkw avatar Oct 14 '20 23:10 hawkw