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

Sergey Matveev earthdok at google.com
Tue Mar 3 08:30:41 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;
----------------
dvyukov wrote:
> earthdok wrote:
> > 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).
> I am assuming nothing. This is existing code. I just properly handle EINTR.
> Is there a simple way to fix other platforms?
As discussed offline: existing code only works correctly (on other platforms) under the assumption that signals are blocked => waitpid does not return until tracer is dead. 

================
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++)
----------------
dvyukov wrote:
> earthdok wrote:
> > There's zero guarantee that it will crash...
> Episodic crashes are fine with me.
> Still much better than the current absence of interesting tests.
As discussed offline, it should actually crash as soon as the ScopedStackSpaceWithGuard object is destroyed. I retract my statement. May be worth a comment.

http://reviews.llvm.org/D8032

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






More information about the llvm-commits mailing list