brintos

brintos / llvm-project-archived public Read only

0
0
Text · 533 B · 6afa14b Raw
25 lines · c
1/// The static TLS block is reused among by threads. The shadow is cleared.2// RUN: %clang_nsan %s -o %t3// RUN: env NSAN_OPTIONS=halt_on_error=1,log2_max_relative_error=19 %run %t4 5#include <pthread.h>6#include <stdio.h>7 8__thread float x;9 10static void *ThreadFn(void *a) {11  long i = (long)a;12  for (long j = i * 1000; j < (i + 1) * 1000; j++)13    x += j;14  printf("%f\n", x);15  return 0;16}17 18int main() {19  pthread_t t;20  for (long i = 0; i < 5; ++i) {21    pthread_create(&t, 0, ThreadFn, (void *)i);22    pthread_join(t, 0);23  }24}25