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

Sergey Matveev earthdok at google.com
Wed Mar 4 11:16:28 PST 2015


We need a comment in sanitizer_stoptheworld.h documenting the fact that the callback must exit by returning and not by calling exit() or _exit().

For the record, this is what currently happens when the tracer dies for any reason:

  If  the  tracer  dies,  all  tracees  are  automatically  detached  and
  restarted,  unless  they  were in group-stop.  Handling of restart from
  group-stop is currently buggy, but the  "as  planned"  behavior  is  to
  leave  tracee  stopped  and  waiting  for  SIGCONT.   If  the tracee is
  restarted from signal-delivery-stop, the pending signal is injected.


================
Comment at: lib/sanitizer_common/sanitizer_stoptheworld_linux_libcdep.cc:214
@@ -208,2 +213,3 @@
       signum, ctx.addr, ctx.pc, ctx.sp);
-  if (thread_suspender_instance != NULL) {
+  ThreadSuspender *inst = thread_suspender_instance;
+  if (inst != NULL) {
----------------
what is the purpose of these changes?

================
Comment at: lib/sanitizer_common/sanitizer_stoptheworld_linux_libcdep.cc:235
@@ -224,3 +234,3 @@
   // a lot of opportunities for that to happen...
-  if (thread_suspender_instance)
-    thread_suspender_instance->KillAllThreads();
+  ThreadSuspender *inst = thread_suspender_instance;
+  if (inst != NULL && stoptheworld_tracer_pid == internal_getpid()) {
----------------
same question

================
Comment at: lib/sanitizer_common/sanitizer_stoptheworld_linux_libcdep.cc:424
@@ +423,3 @@
+    // NOTE: errno is shared between this thread and the tracer thread.
+    // internal_waitpid can access/spoil errno, so we can't call it now.
+    // Instead we for the tracer thread to finish using the spin loop below.
----------------
internal_waitpid() may call syscall() which can access/spoil...

http://reviews.llvm.org/D8032

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






More information about the llvm-commits mailing list