Closed
Description
When thread locals are dropped, the thread is not valid anymore so accessing thread::current()
will panic, however, begin_unwind
calls thread::current()
which will cause an infinite loop and a stack overflow.
The follow example has been tested to crash with an out of memory error on OS X:
use std::thread;
struct Handle {
i: i32,
}
impl Drop for Handle {
fn drop(&mut self) {
panic!("BOOM");
}
}
thread_local!(static HANDLE: Handle = new_handle());
fn new_handle() -> Handle {
Handle { i: 0 }
}
pub fn main() {
let _ = thread::scoped(|| {
HANDLE.with(|h| {
println!("HANDLE: {}", h.i);
});
});
}