]>
git.proxmox.com Git - rustc.git/blob - src/libcompiler_builtins/compiler-rt/test/tsan/mutexset7.cc
1 // RUN: %clangxx_tsan -O1 %s -o %t && %deflake %run %t | FileCheck %s
5 __thread
int huge
[1024*1024];
7 void *Thread1(void *x
) {
8 barrier_wait(&barrier
);
13 void *Thread2(void *x
) {
14 pthread_mutex_t
*mtx
= new pthread_mutex_t
;
15 pthread_mutex_init(mtx
, 0);
16 pthread_mutex_lock(mtx
);
18 pthread_mutex_unlock(mtx
);
19 pthread_mutex_destroy(mtx
);
21 barrier_wait(&barrier
);
26 barrier_init(&barrier
, 2);
28 pthread_create(&t
[0], NULL
, Thread1
, NULL
);
29 pthread_create(&t
[1], NULL
, Thread2
, NULL
);
30 pthread_join(t
[0], NULL
);
31 pthread_join(t
[1], NULL
);
34 // CHECK: WARNING: ThreadSanitizer: data race
35 // CHECK: Write of size 4 at {{.*}} by thread T1:
36 // CHECK: Previous write of size 4 at {{.*}} by thread T2
37 // CHECK: (mutexes: write [[M1:M[0-9]+]]):
38 // CHECK: Mutex [[M1]] is already destroyed
39 // CHECK-NOT: Mutex {{.*}} created at