[ASan/Win] Add a comment about DCL-using-static vs threads
[blocksruntime.git] / test / tsan / signal_malloc.cc
blobf6fc3facb3d0087f29a83e749ecd8c710eae5deb
1 // RUN: %clang_tsan -O1 %s -o %t && not %run %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>
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);
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;