about summary refs log tree commit diff
path: root/src/tools/miri/tests/fail/tls/tls_static_dealloc.rs
blob: c72cc8114dac4f956af9360a43411c6d33ee8fd9 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
//! Ensure that thread-local statics get deallocated when the thread dies.

#![feature(thread_local)]

use std::ptr::addr_of;

#[thread_local]
static mut TLS: u8 = 0;

struct SendRaw(*const u8);
unsafe impl Send for SendRaw {}

fn main() {
    unsafe {
        let dangling_ptr = std::thread::spawn(|| SendRaw(addr_of!(TLS))).join().unwrap();
        let _val = *dangling_ptr.0; //~ ERROR: has been freed
    }
}