[PATCH] tsan: fix signal handling during stop-the-world

Sergey Matveev earthdok at google.com
Tue Mar 3 07:09:47 PST 2015


================
Comment at: lib/sanitizer_common/sanitizer_stoptheworld_linux_libcdep.cc:416
@@ +415,3 @@
+      uptr waitpid_status = internal_waitpid(tracer_pid, NULL, __WALL);
+      if (!internal_iserror(waitpid_status, &local_errno))
+        break;
----------------
Wrong. You're assuming that internal_waitpid() will not touch errno. This is true only on x86_64 Linux where we have our custom wrappers implemented. Other platforms (MIPS, ARM) use the libc implementation (see sanitizer_syscall_generic.inc).

================
Comment at: test/asan/TestCases/Linux/leak_check_segv.cc:2
@@ +1,3 @@
+// Test that SIGSEGV during leak checking does not crash the process.
+// RUN: %clangxx_asan -O1 %s -o %t -pthread && LSAN_OPTIONS="verbosity=1" not %run %t 2>&1
+// REQUIRES: asan-64-bits
----------------
-pthread is unnecessary with asan
if you want to use it at least be consistent (-pthread/-lpthread)

================
Comment at: test/asan/TestCases/Linux/signal_during_stop_the_world.cc:5
@@ +4,3 @@
+
+// RUN: %clangxx_asan -O1 -lpthread %s -o %t && %run %t 2>&1 | FileCheck %s
+
----------------
see above

================
Comment at: test/asan/TestCases/Linux/signal_during_stop_the_world.cc:37
@@ +36,3 @@
+    for (;;) {
+      kill(parent, SIGCHLD);
+      kill(parent, SIGPROF);
----------------
Why these two signals in particular?

================
Comment at: test/asan/TestCases/Linux/signal_during_stop_the_world.cc:43
@@ +42,3 @@
+  void *mem[1000];
+  for (int i = 0; i < 1000; i++)
+    mem[i] = malloc(1000);
----------------
This barely makes a difference, the time spent attaching to threads will probably be >> this.

If you want to slow down leak detection you could make a few large allocs and fill the memory with pointers to them. 

================
Comment at: test/asan/TestCases/Linux/signal_during_stop_the_world.cc:54
@@ +53,3 @@
+  waitpid(pid, 0, 0);
+  sleep(1);  // If the tracer thread still runs, give it time to crash.
+  for (int i = 0; i < 1000; i++)
----------------
There's zero guarantee that it will crash...

http://reviews.llvm.org/D8032

EMAIL PREFERENCES
  http://reviews.llvm.org/settings/panel/emailpreferences/






More information about the llvm-commits mailing list