2022-07-08 11:08:32 -05:00
|
|
|
//@ignore-windows: Concurrency on Windows is not supported yet.
|
2020-07-27 05:53:39 -05:00
|
|
|
|
|
|
|
//! Ensure that thread-local statics get deallocated when the thread dies.
|
|
|
|
|
|
|
|
#![feature(thread_local)]
|
|
|
|
|
|
|
|
#[thread_local]
|
|
|
|
static mut TLS: u8 = 0;
|
|
|
|
|
2022-06-26 20:26:14 -05:00
|
|
|
struct SendRaw(*const u8);
|
|
|
|
unsafe impl Send for SendRaw {}
|
|
|
|
|
2022-06-21 13:27:44 -05:00
|
|
|
fn main() {
|
|
|
|
unsafe {
|
2022-06-26 20:26:14 -05:00
|
|
|
let dangling_ptr = std::thread::spawn(|| SendRaw(&TLS as *const u8)).join().unwrap();
|
|
|
|
let _val = *dangling_ptr.0; //~ ERROR dereferenced after this allocation got freed
|
2022-06-21 13:27:44 -05:00
|
|
|
}
|
|
|
|
}
|