summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlexey Samsonov <samsonov@google.com>2013-04-19 08:04:46 +0000
committerAlexey Samsonov <samsonov@google.com>2013-04-19 08:04:46 +0000
commit6021e94774d94dc7be45ffcf545563b995542a1a (patch)
tree5bec423c921194a75e15e079f926b1c57d8e1987
parent0e89ade8ffb24ae1b2b024151d41c17acd67d678 (diff)
downloadbcm5719-llvm-6021e94774d94dc7be45ffcf545563b995542a1a.tar.gz
bcm5719-llvm-6021e94774d94dc7be45ffcf545563b995542a1a.zip
[TSan] Allocate fd table in user heap instead of using internal allocator. We need this to catch races on fds.
llvm-svn: 179841
-rw-r--r--compiler-rt/lib/tsan/rtl/tsan_fd.cc5
1 files changed, 3 insertions, 2 deletions
diff --git a/compiler-rt/lib/tsan/rtl/tsan_fd.cc b/compiler-rt/lib/tsan/rtl/tsan_fd.cc
index b3cb88488b2..14bdbb53b32 100644
--- a/compiler-rt/lib/tsan/rtl/tsan_fd.cc
+++ b/compiler-rt/lib/tsan/rtl/tsan_fd.cc
@@ -74,13 +74,14 @@ static FdDesc *fddesc(ThreadState *thr, uptr pc, int fd) {
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
}
OpenPOWER on IntegriCloud