[compiler-rt] r179841 - [TSan] Allocate fd table in user heap instead of using internal allocator. We need this to catch races on fds.

Alexey Samsonov samsonov at google.com
Fri Apr 19 01:04:48 PDT 2013


Author: samsonov
Date: Fri Apr 19 03:04:46 2013
New Revision: 179841

URL: http://llvm.org/viewvc/llvm-project?rev=179841&view=rev
Log:
[TSan] Allocate fd table in user heap instead of using internal allocator. We need this to catch races on fds.

Modified:
    compiler-rt/trunk/lib/tsan/rtl/tsan_fd.cc

Modified: compiler-rt/trunk/lib/tsan/rtl/tsan_fd.cc
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/tsan/rtl/tsan_fd.cc?rev=179841&r1=179840&r2=179841&view=diff
==============================================================================
--- compiler-rt/trunk/lib/tsan/rtl/tsan_fd.cc (original)
+++ compiler-rt/trunk/lib/tsan/rtl/tsan_fd.cc Fri Apr 19 03:04:46 2013
@@ -74,13 +74,14 @@ static FdDesc *fddesc(ThreadState *thr,
   uptr l1 = atomic_load(pl1, memory_order_consume);
   if (l1 == 0) {
     uptr size = kTableSizeL2 * sizeof(FdDesc);
-    void *p = internal_alloc(MBlockFD, size);
+    // We need this to reside in user memory to properly catch races on it.
+    void *p = user_alloc(thr, pc, size);
     internal_memset(p, 0, size);
     MemoryResetRange(thr, (uptr)&fddesc, (uptr)p, size);
     if (atomic_compare_exchange_strong(pl1, &l1, (uptr)p, memory_order_acq_rel))
       l1 = (uptr)p;
     else
-      internal_free(p);
+      user_free(thr, pc, p);
   }
   return &((FdDesc*)l1)[fd % kTableSizeL2];  // NOLINT
 }





More information about the llvm-commits mailing list