1 // RUN: %clang_dfsan %s -o %t && %run %t
3 // RUN: %clang_dfsan -gmlt -mllvm -dfsan-track-origins=1 %s -o %t && \
4 // RUN: %run %t >%t.out 2>&1
5 // RUN: FileCheck %s < %t.out
7 // RUN: %clang_dfsan -gmlt -mllvm -dfsan-track-origins=1 -mllvm -dfsan-instrument-with-call-threshold=0 %s -o %t && \
8 // RUN: %run %t >%t.out 2>&1
9 // RUN: FileCheck %s < %t.out
11 #include <sanitizer/dfsan_interface.h>
17 const int kNumThreads
= 24;
21 static void *ThreadFn(void *a
) {
23 assert(dfsan_get_label(y
) == 8);
24 memcpy(&z
, &y
, sizeof(y
));
26 dfsan_print_origin_trace(&z
, NULL
);
31 dfsan_set_label(8, &x
, sizeof(x
));
33 pthread_t t
[kNumThreads
];
34 for (size_t i
= 0; i
< kNumThreads
; ++i
)
35 pthread_create(&t
[i
], 0, ThreadFn
, (void *)i
);
37 for (size_t i
= 0; i
< kNumThreads
; ++i
)
38 pthread_join(t
[i
], 0);
43 // CHECK: Taint value 0x8 {{.*}} origin tracking ()
44 // CHECK: Origin value: {{.*}}, Taint value was stored to memory at
45 // CHECK: #0 {{.*}} in ThreadFn.dfsan {{.*}}pthread.c:[[@LINE-21]]
47 // CHECK: Origin value: {{.*}}, Taint value was stored to memory at
48 // CHECK: #0 {{.*}} in ThreadFn.dfsan {{.*}}pthread.c:[[@LINE-26]]
50 // CHECK: Origin value: {{.*}}, Taint value was created at
51 // CHECK: #0 {{.*}} in main {{.*}}pthread.c:[[@LINE-20]]