• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // Test that blacklisted functions are still contained in the stack trace.
2 
3 // RUN: echo "fun:*Blacklisted_Thread2*" > %t.blacklist
4 // RUN: echo "fun:*CallTouchGlobal*" >> %t.blacklist
5 
6 // RUN: %clangxx_tsan -O1 %s -fsanitize-blacklist=%t.blacklist -o %t
7 // RUN: %deflake %run %t 2>&1 | FileCheck %s
8 #include "test.h"
9 
10 int Global;
11 
Thread1(void * x)12 void *Thread1(void *x) {
13   barrier_wait(&barrier);
14   // CHECK: ThreadSanitizer: data race
15   // CHECK: Write of size 4
16   // CHECK: #0 Thread1{{.*}}blacklist2.cpp:[[@LINE+1]]
17   Global++;
18   return NULL;
19 }
20 
TouchGlobal()21 void TouchGlobal() {
22   // CHECK: Previous write of size 4
23   // CHECK: #0 TouchGlobal{{.*}}blacklist2.cpp:[[@LINE+1]]
24   Global--;
25 }
26 
CallTouchGlobal()27 void CallTouchGlobal() {
28   // CHECK: #1 CallTouchGlobal{{.*}}blacklist2.cpp:[[@LINE+1]]
29   TouchGlobal();
30 }
31 
Blacklisted_Thread2(void * x)32 void *Blacklisted_Thread2(void *x) {
33   Global--;
34   // CHECK: #2 Blacklisted_Thread2{{.*}}blacklist2.cpp:[[@LINE+1]]
35   CallTouchGlobal();
36   barrier_wait(&barrier);
37   return NULL;
38 }
39 
main()40 int main() {
41   barrier_init(&barrier, 2);
42   pthread_t t[2];
43   pthread_create(&t[0], NULL, Thread1, NULL);
44   pthread_create(&t[1], NULL, Blacklisted_Thread2, NULL);
45   pthread_join(t[0], NULL);
46   pthread_join(t[1], NULL);
47   fprintf(stderr, "PASS\n");
48   return 0;
49 }
50