brintos

brintos / llvm-project-archived public Read only

0
0
Text · 630 B · 5ee94e9 Raw
29 lines · c
1// RUN: %clang_tsan -O1 %s -o %t && %run %t 2>&1 | FileCheck %s2#include "test.h"3 4// Test for https://llvm.org/bugs/show_bug.cgi?id=232355// The bug was that synchronization between thread creation and thread start6// is not established if pthread_create is followed by pthread_detach.7 8int x;9 10void *Thread(void *a) {11  x = 42;12  barrier_wait(&barrier);13  return 0;14}15 16int main() {17  barrier_init(&barrier, 2);18  pthread_t t;19  x = 43;20  pthread_create(&t, 0, Thread, 0);21  pthread_detach(t);22  barrier_wait(&barrier);23  fprintf(stderr, "PASS\n");24  return 0;25}26 27// CHECK-NOT: WARNING: ThreadSanitizer: data race28// CHECK: PASS29