1 // Test that TLS is unpoisoned on thread death.
2 // REQUIRES: x86-target-arch && !android
4 // RUN: %clangxx_asan -O0 %s -pthread -o %t && %run %t 2>&1
5 // RUN: %clangxx_asan -O1 %s -pthread -o %t && %run %t 2>&1
11 #include <sanitizer/asan_interface.h>
13 __thread
int64_t tls_var
[2];
15 volatile int64_t *p_tls_var
;
17 void *first(void *arg
) {
18 ASAN_POISON_MEMORY_REGION(&tls_var
, sizeof(tls_var
));
23 void *second(void *arg
) {
24 assert(tls_var
== p_tls_var
);
29 int main(int argc
, char *argv
[]) {
31 assert(0 == pthread_create(&p
, 0, first
, 0));
32 assert(0 == pthread_join(p
, 0));
33 assert(0 == pthread_create(&p
, 0, second
, 0));
34 assert(0 == pthread_join(p
, 0));