2014-05-30 22:08:51 +08:00
|
|
|
// RUN: %clang_tsan -O1 %s -o %t && %deflake %run %t | FileCheck %s
|
2015-01-21 21:50:02 +08:00
|
|
|
#include "test.h"
|
2012-12-14 21:56:27 +08:00
|
|
|
#include <signal.h>
|
|
|
|
#include <sys/types.h>
|
|
|
|
|
|
|
|
static void handler(int, siginfo_t*, void*) {
|
2012-12-28 16:38:09 +08:00
|
|
|
// CHECK: WARNING: ThreadSanitizer: signal-unsafe call inside of a signal
|
|
|
|
// CHECK: #0 malloc
|
2014-10-09 17:40:02 +08:00
|
|
|
// CHECK: #{{(1|2)}} handler(int, {{(__)?}}siginfo{{(_t)?}}*, void*) {{.*}}signal_malloc.cc:[[@LINE+2]]
|
2013-02-06 22:24:00 +08:00
|
|
|
// CHECK: SUMMARY: ThreadSanitizer: signal-unsafe call inside of a signal{{.*}}handler
|
2012-12-14 21:56:27 +08:00
|
|
|
volatile char *p = (char*)malloc(1);
|
|
|
|
p[0] = 0;
|
|
|
|
free((void*)p);
|
|
|
|
}
|
|
|
|
|
|
|
|
int main() {
|
|
|
|
struct sigaction act = {};
|
|
|
|
act.sa_sigaction = &handler;
|
|
|
|
sigaction(SIGPROF, &act, 0);
|
|
|
|
kill(getpid(), SIGPROF);
|
2015-01-21 21:50:02 +08:00
|
|
|
sleep(1); // let the signal handler run
|
2012-12-14 21:56:27 +08:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|