diff options
author | Alexey Samsonov <samsonov@google.com> | 2013-04-19 08:04:46 +0000 |
---|---|---|
committer | Alexey Samsonov <samsonov@google.com> | 2013-04-19 08:04:46 +0000 |
commit | 77330179d0c0fe876f3b89fca9a23c4504b1e692 (patch) | |
tree | ff4d5dd392b318723238fc15816505ed9c33a93a /lib | |
parent | 99f1e2011a855edd3b1036660ec5e7b70aa06520 (diff) | |
download | compiler-rt-77330179d0c0fe876f3b89fca9a23c4504b1e692.tar.gz |
[TSan] Allocate fd table in user heap instead of using internal allocator. We need this to catch races on fds.
git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@179841 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib')
-rw-r--r-- | lib/tsan/rtl/tsan_fd.cc | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/lib/tsan/rtl/tsan_fd.cc b/lib/tsan/rtl/tsan_fd.cc index b3cb88488..14bdbb53b 100644 --- a/lib/tsan/rtl/tsan_fd.cc +++ b/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 } |