xref: /llvm-project/compiler-rt/test/tsan/mutex_bad_read_unlock.cpp (revision 8214764f35e1b764fb939e18f16e11aa43073469)
1bcaeed49SFangrui Song // RUN: %clangxx_tsan -O1 %s -o %t && %deflake %run %t | FileCheck %s
2*8214764fSDmitry Vyukov #include "test.h"
3bcaeed49SFangrui Song 
main()4bcaeed49SFangrui Song int main() {
5bcaeed49SFangrui Song   int m = 0;
6bcaeed49SFangrui Song   AnnotateRWLockAcquired(__FILE__, __LINE__, &m, 1);
7bcaeed49SFangrui Song   AnnotateRWLockReleased(__FILE__, __LINE__, &m, 0);
8bcaeed49SFangrui Song   return 0;
9bcaeed49SFangrui Song }
10bcaeed49SFangrui Song 
11bcaeed49SFangrui Song // CHECK: WARNING: ThreadSanitizer: read unlock of a write locked mutex
12bcaeed49SFangrui Song // CHECK:     #0 AnnotateRWLockReleased
13bcaeed49SFangrui Song // CHECK:     #1 main
14bcaeed49SFangrui Song // CHECK: Location is stack of main thread.
15bcaeed49SFangrui Song // CHECK:   Mutex {{.*}}) created at:
16bcaeed49SFangrui Song // CHECK:     #0 AnnotateRWLockAcquired
17bcaeed49SFangrui Song // CHECK:     #1 main
18bcaeed49SFangrui Song // CHECK: SUMMARY: ThreadSanitizer: read unlock of a write locked mutex
19bcaeed49SFangrui Song 
20