brintos

brintos / llvm-project-archived public Read only

0
0
Text · 733 B · 2bef93a Raw
27 lines · cpp
1// RUN: %clangxx_tsan -O1 %s -o %t && %deflake %run %t | FileCheck %s2#include "test.h"3 4void *ThreadFunc(void *m) {5  AnnotateRWLockAcquired(__FILE__, __LINE__, m, 1);6  return 0;7}8 9int main() {10  int m = 0;11  AnnotateRWLockAcquired(__FILE__, __LINE__, &m, 1);12  pthread_t th;13  pthread_create(&th, 0, ThreadFunc, &m);14  pthread_join(th, 0);15  return 0;16}17 18// CHECK: WARNING: ThreadSanitizer: double lock of a mutex19// CHECK:     #0 AnnotateRWLockAcquired20// CHECK:     #1 ThreadFunc21// CHECK: Location is stack of main thread.22// CHECK:   Mutex {{.*}} created at:23// CHECK:     #0 AnnotateRWLockAcquired24// CHECK:     #1 main25// CHECK: SUMMARY: ThreadSanitizer: double lock of a mutex {{.*}}mutex_double_lock.cpp{{.*}}ThreadFunc26 27