brintos

brintos / llvm-project-archived public Read only

0
0
Text · 448 B · 78a328f Raw
27 lines · cpp
1// RUN: %clangxx_msan -O0 %s -o %t && %run %t2 3// Check that when TLS block is reused between threads, its shadow is cleaned.4 5#include <pthread.h>6#include <stdio.h>7 8int __thread x;9 10void *ThreadFn(void *) {11  if (!x)12    printf("zzz\n");13  int y;14  int * volatile p = &y;15  x = *p;16  return 0;17}18 19int main(void) {20  pthread_t t;21  for (int i = 0; i < 100; ++i) {22    pthread_create(&t, 0, ThreadFn, 0);23    pthread_join(t, 0);24  }25  return 0;26}27