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 <pthread.h> 9#include <stdio.h> 10#include <unistd.h> 11 12int Global; 13 14void *Thread1(void *x) { 15 sleep(1); 16 // CHECK: ThreadSanitizer: data race 17 // CHECK: Write of size 4 18 // CHECK: #0 Thread1{{.*}}blacklist2.cc:[[@LINE+1]] 19 Global++; 20 return NULL; 21} 22 23void TouchGlobal() { 24 // CHECK: Previous write of size 4 25 // CHECK: #0 TouchGlobal(){{.*}}blacklist2.cc:[[@LINE+1]] 26 Global--; 27} 28 29void CallTouchGlobal() { 30 // CHECK: #1 CallTouchGlobal{{.*}}blacklist2.cc:[[@LINE+1]] 31 TouchGlobal(); 32} 33 34void *Blacklisted_Thread2(void *x) { 35 Global--; 36 // CHECK: #2 Blacklisted_Thread2{{.*}}blacklist2.cc:[[@LINE+1]] 37 CallTouchGlobal(); 38 return NULL; 39} 40 41int main() { 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 printf("PASS\n"); 48 return 0; 49} 50