[PATCH] [ASan, LSan] Improve tracking of thread creation.

Alexey Samsonov vonosmas at gmail.com
Mon Dec 1 19:26:51 PST 2014


================
Comment at: lib/asan/asan_interceptors.cc:197
@@ +196,3 @@
+    asanThreadRegistry().CreateThread(*(uptr*)t, detached, current_tid, &args);
+    atomic_store(&atomic_t, reinterpret_cast<uptr>(t), memory_order_release);
+    while (atomic_load(&atomic_t, memory_order_acquire) != 0)
----------------
Reusing the same atomic_uintptr_t for different purpose looks kind of confusing. IIUC first we use it to publish the pointer to AsanThread*, and then use it to signal that the thread is registered (and you need one more argument to AsanThread::ThreadStart for this purpose).

Would it be cleaner to have
  atomic_uintptr_t registered
as a field of AsanThread object? You can atomically set it inside ThreadStart() and call t->WaitUntilRegistered() here.

http://reviews.llvm.org/D6441






More information about the llvm-commits mailing list