aboutsummaryrefslogtreecommitdiff
path: root/libsanitizer/tsan/tsan_fd.cc
diff options
context:
space:
mode:
Diffstat (limited to 'libsanitizer/tsan/tsan_fd.cc')
-rw-r--r--libsanitizer/tsan/tsan_fd.cc7
1 files changed, 4 insertions, 3 deletions
diff --git a/libsanitizer/tsan/tsan_fd.cc b/libsanitizer/tsan/tsan_fd.cc
index a75d9bd..de852b1 100644
--- a/libsanitizer/tsan/tsan_fd.cc
+++ b/libsanitizer/tsan/tsan_fd.cc
@@ -72,13 +72,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
}
@@ -157,9 +158,9 @@ void FdRelease(ThreadState *thr, uptr pc, int fd) {
FdDesc *d = fddesc(thr, pc, fd);
FdSync *s = d->sync;
DPrintf("#%d: FdRelease(%d) -> %p\n", thr->tid, fd, s);
+ MemoryRead(thr, pc, (uptr)d, kSizeLog8);
if (s)
Release(thr, pc, (uptr)s);
- MemoryRead(thr, pc, (uptr)d, kSizeLog8);
}
void FdAccess(ThreadState *thr, uptr pc, int fd) {