1 // Check that stores in signal handlers are not recorded in origin history.
3 // Origin tracking uses ChainedOriginDepot that is not async signal safe, so we
4 // do not track origins inside signal handlers.
6 // RUN: %clangxx_dfsan -gmlt -mllvm -dfsan-track-origins=1 %s -o %t && \
7 // RUN: %run %t >%t.out 2>&1
8 // RUN: FileCheck %s < %t.out
10 // RUN: %clangxx_dfsan -gmlt -mllvm -dfsan-instrument-with-call-threshold=0 -mllvm -dfsan-track-origins=1 %s -o %t && \
11 // RUN: %run %t >%t.out 2>&1
12 // RUN: FileCheck %s < %t.out
14 #include <sanitizer/dfsan_interface.h>
18 #include <sys/types.h>
23 void SignalHandler(int signo
) {
25 memcpy(&u
, &y
, sizeof(int));
28 int main(int argc
, char *argv
[]) {
30 dfsan_set_label(8, &z
, sizeof(z
));
33 signal(SIGHUP
, SignalHandler
);
34 kill(getpid(), SIGHUP
);
35 signal(SIGHUP
, SIG_DFL
);
37 dfsan_print_origin_trace(&u
, nullptr);
41 // CHECK: Taint value 0x8 {{.*}} origin tracking ()
42 // CHECK: Origin value: {{.*}}, Taint value was stored to memory at
43 // CHECK-NOT: {{.*}} in SignalHandler.dfsan {{.*}}origin_with_signals.cpp{{.*}}
45 // CHECK: #0 {{.*}} in main {{.*}}origin_with_signals.cpp:[[@LINE-14]]
47 // CHECK: Origin value: {{.*}}, Taint value was created at
48 // CHECK: #0 {{.*}} in main {{.*}}origin_with_signals.cpp:[[@LINE-18]]