[PATCH] StopTheWorld in sanitizer_common (first commit)

Dmitry Vyukov dvyukov at google.com
Tue Mar 12 09:00:09 PDT 2013



================
Comment at: lib/sanitizer_common/sanitizer_stoptheworld_linux.cc:96
@@ +95,3 @@
+    return false;
+  if (internal_ptrace(PTRACE_ATTACH, thread_id, NULL, NULL) != 0) {
+    // Either the thread is dead, or something prevented us from attaching.
----------------
s/NULL/0/
here and below
the codebase does not use NULL

================
Comment at: lib/sanitizer_common/sanitizer_stoptheworld_linux.cc:99
@@ +98,3 @@
+    // Log this event and move on.
+    Report("Could not attach to thread %d.\n", thread_id);
+    return false;
----------------
append errno

================
Comment at: lib/sanitizer_common/sanitizer_stoptheworld_linux.cc:111
@@ +110,3 @@
+      // doesn't hurt to report it.
+      Report("Waiting on thread %d failed, detaching.\n", thread_id);
+      internal_ptrace(PTRACE_DETACH, thread_id, NULL, NULL);
----------------
append errno

================
Comment at: lib/sanitizer_common/sanitizer_stoptheworld_linux.cc:130
@@ +129,3 @@
+      // from a signal handler.
+      Report("Could not detach from thread %d.\n", tid);
+    }
----------------
append errno

================
Comment at: lib/sanitizer_common/sanitizer_stoptheworld_linux.cc:158
@@ +157,3 @@
+    }
+    thread_lister.Reset();
+  } while (added_threads);
----------------
will it report new threads provided that you do not reopen the dirent?

================
Comment at: lib/sanitizer_common/sanitizer_stoptheworld_linux.cc:293
@@ +292,3 @@
+  if (tracer_pid < 0) {
+    Report("Failed spawning a tracer thread.\n");
+    tracer_init_mutex.Unlock();
----------------
add errno

================
Comment at: lib/sanitizer_common/sanitizer_stoptheworld_linux.cc:62
@@ +61,3 @@
+//
+// * The following functions are safe to use because they are called either
+// before the cloned thread is spawned, or after it has exited.
----------------
I guess it's safe to use any functions before the cloned thread is spawned, or after it has exited, or only these?

================
Comment at: lib/sanitizer_common/tests/sanitizer_stoptheworld_test.cc:76
@@ +75,3 @@
+  pthread_mutex_lock(&incrementer_thread_exit_mutex);
+  pthread_create_result = pthread_create(&thread_id, NULL, IncrementerThread,
+                                         &argument);
----------------
I would be great to have a more comprehensive test where more threads are created, and in particular threads are created and destroyed concurrently with stop-the-world.


http://llvm-reviews.chandlerc.com/D469



More information about the llvm-commits mailing list