1 // RUN: %clang_tsan -O1 %s -o %t && not %t 2>&1 | FileCheck %s 2 #include <stdio.h> 3 #include <stdlib.h> 4 #include <signal.h> 5 #include <sys/types.h> 6 #include <unistd.h> 7 8 static void handler(int, siginfo_t*, void*) { 9 // CHECK: WARNING: ThreadSanitizer: signal-unsafe call inside of a signal 10 // CHECK: #0 malloc 11 // CHECK: #{{(1|2)}} handler(int, siginfo{{(_t)?}}*, void*) {{.*}}signal_malloc.cc:[[@LINE+2]] 12 // CHECK: SUMMARY: ThreadSanitizer: signal-unsafe call inside of a signal{{.*}}handler 13 volatile char *p = (char*)malloc(1); 14 p[0] = 0; 15 free((void*)p); 16 } 17 18 int main() { 19 struct sigaction act = {}; 20 act.sa_sigaction = &handler; 21 sigaction(SIGPROF, &act, 0); 22 kill(getpid(), SIGPROF); 23 sleep(1); 24 return 0; 25 } 26 27