[PATCH] D14328: [tsan] Handle libdispatch worker threads on OS X

Dmitry Vyukov via llvm-commits llvm-commits at lists.llvm.org
Wed Nov 4 10:52:50 PST 2015


dvyukov added a comment.

> How do we deal with these in ASan?


In asan we can deal with the case when we don't have an initialized thread:

  AsanThread *t = GetCurrentThread();
  void *allocated;
  bool check_rss_limit = true;
  if (t) {
    AllocatorCache *cache = GetAllocatorCache(&t->malloc_storage());
    allocated =
        allocator.Allocate(cache, needed_size, 8, false, check_rss_limit);
  } else {
    SpinMutexLock l(&fallback_mutex);
    AllocatorCache *cache = &fallback_allocator_cache;
    allocated =
        allocator.Allocate(cache, needed_size, 8, false, check_rss_limit);
  }

That was added due to the same problems we are now struggling with tsan (bootstrap, thread start/end on different platforms). But it was easier to solve as in asan thread state is used only as an optimization. This path uses a global mutex for all allocations and deallocations, and so is extremely slow, that is fine because it is meant to be used only during said short periods of time.

Now I wonder if this path is actually heavily used in some contexts (e.g. mac + gcd), but nobody noticed.


Repository:
  rL LLVM

http://reviews.llvm.org/D14328





More information about the llvm-commits mailing list