llvm-project
23 строки · 535.0 Байт
1// RUN: %clang_tsan -O1 %s -o %t && %deflake %run %t | FileCheck %s
2#include "test.h"3
4void *Thread(void *x) {5pthread_mutex_lock((pthread_mutex_t*)x);6pthread_mutex_unlock((pthread_mutex_t*)x);7barrier_wait(&barrier);8return 0;9}
10
11int main() {12barrier_init(&barrier, 2);13pthread_mutex_t Mtx;14pthread_mutex_init(&Mtx, 0);15pthread_t t;16pthread_create(&t, 0, Thread, &Mtx);17barrier_wait(&barrier);18pthread_mutex_destroy(&Mtx);19pthread_join(t, 0);20return 0;21}
22
23// CHECK: WARNING: ThreadSanitizer: data race
24