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

source code of compiler-rt/test/tsan/ignorelist2.cpp