[PATCH] [lsan] Handle fork() correctly.

Alexey Samsonov samsonov at google.com
Mon Jul 22 01:29:01 PDT 2013


  Can you please clarify why we it is necessary to ensure correct os_id before pthread_create?


================
Comment at: lib/asan/asan_thread.cc:259
@@ +258,3 @@
+void EnsureMainThreadIsCorrect() {
+  AsanThreadContext *context = (AsanThreadContext*)AsanTSDGet();
+  if (context && (context->tid == 0))
----------------
static_cast here for consistency.

================
Comment at: lib/asan/asan_interceptors.cc:141
@@ -140,2 +140,3 @@
     void *attr, void *(*start_routine)(void*), void *arg) {
+  EnsureMainThreadIsCorrect();
   // Strict init-order checking in thread-hostile.
----------------
Please add this to CreateThread() interceptor as well.

================
Comment at: lib/asan/asan_thread.h:127
@@ -126,1 +126,3 @@
 
+// Used to handle fork().
+void EnsureMainThreadIsCorrect();
----------------
I think the comment needs to be more explicit.


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



More information about the llvm-commits mailing list