[llvm-commits] [compiler-rt] r170205 - /compiler-rt/trunk/lib/tsan/lit_tests/signal_malloc.cc
Dmitry Vyukov
dvyukov at google.com
Fri Dec 14 05:56:27 PST 2012
Author: dvyukov
Date: Fri Dec 14 07:56:27 2012
New Revision: 170205
URL: http://llvm.org/viewvc/llvm-project?rev=170205&view=rev
Log:
tsan: add test for malloc/free in signal handler
Added:
compiler-rt/trunk/lib/tsan/lit_tests/signal_malloc.cc
Added: compiler-rt/trunk/lib/tsan/lit_tests/signal_malloc.cc
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/tsan/lit_tests/signal_malloc.cc?rev=170205&view=auto
==============================================================================
--- compiler-rt/trunk/lib/tsan/lit_tests/signal_malloc.cc (added)
+++ compiler-rt/trunk/lib/tsan/lit_tests/signal_malloc.cc Fri Dec 14 07:56:27 2012
@@ -0,0 +1,26 @@
+// RUN: %clang_tsan -O1 %s -o %t && %t 2>&1 | FileCheck %s
+#include <stdio.h>
+#include <stdlib.h>
+#include <signal.h>
+#include <sys/types.h>
+#include <unistd.h>
+
+static void handler(int, siginfo_t*, void*) {
+ 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);
+ sleep(1);
+ return 0;
+}
+
+// CHECK: WARNING: ThreadSanitizer: signal-unsafe call inside of a signal
+// CHECK: #0 malloc
+// CHECK: #1 handler(int, siginfo*, void*) {{.*}}signal_malloc.cc:9
+
More information about the llvm-commits
mailing list