I'm trying to get to the bottom of a weird crash I'm getting. I have minimal reproducible here:
https://github.com/gerwin3/thread-local-accesserror-repro/blob/main/src/main.rs
System:
- Arch Linux x86_64 6.7.6-arch1-1
- AMD Ryzen 9 5900X
To trigger the crash: close the window with CTRL + W.
The app uses egui and tracing-appender and the combination somehow triggers an AccessError (cannot access a Thread Local Storage value during or after destruction: AccessError) that eventually is caused by a function get_slow in thread_local:
|
THREAD_GUARD.with(|guard| guard.id.set(new.id)); |
My guess is that calling with on a thread local may not always be correct if the caller is running a destructor (?) in any case the docs of LocalKey::with seem to suggest so: https://doc.rust-lang.org/std/thread/struct.LocalKey.html#method.with
Not sure if I'm on the right track here. But since the documentation on this crate does not seem to suggest that ThreadLocal::get can panic in certain situations, and it seems it can actually panic in this case it seems this is a bug.
I'm trying to get to the bottom of a weird crash I'm getting. I have minimal reproducible here:
https://github.com/gerwin3/thread-local-accesserror-repro/blob/main/src/main.rs
System:
To trigger the crash: close the window with CTRL + W.
The app uses
eguiandtracing-appenderand the combination somehow triggers anAccessError(cannot access a Thread Local Storage value during or after destruction: AccessError) that eventually is caused by a functionget_slowinthread_local:thread_local-rs/src/thread_id.rs
Line 169 in 6920311
My guess is that calling
withon a thread local may not always be correct if the caller is running a destructor (?) in any case the docs ofLocalKey::withseem to suggest so: https://doc.rust-lang.org/std/thread/struct.LocalKey.html#method.withNot sure if I'm on the right track here. But since the documentation on this crate does not seem to suggest that
ThreadLocal::getcan panic in certain situations, and it seems it can actually panic in this case it seems this is a bug.