summaryrefslogtreecommitdiff
path: root/lib/tsan/rtl/tsan_mman.cc
diff options
context:
space:
mode:
authorDmitry Vyukov <dvyukov@google.com>2013-09-20 05:37:36 +0000
committerDmitry Vyukov <dvyukov@google.com>2013-09-20 05:37:36 +0000
commitff90a95c26198e9e794e186365a62511439e0ca0 (patch)
tree7b7099e8fd91ddf5f8d070c876009ce42295c96b /lib/tsan/rtl/tsan_mman.cc
parent9880219fc988d9fd60c8aa21c0f6f0e0d7370dd6 (diff)
tsan: allow to ignore memory accesses in malloc and free
git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@191072 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/tsan/rtl/tsan_mman.cc')
-rw-r--r--lib/tsan/rtl/tsan_mman.cc14
1 files changed, 10 insertions, 4 deletions
diff --git a/lib/tsan/rtl/tsan_mman.cc b/lib/tsan/rtl/tsan_mman.cc
index 957479039..8547f714b 100644
--- a/lib/tsan/rtl/tsan_mman.cc
+++ b/lib/tsan/rtl/tsan_mman.cc
@@ -110,8 +110,12 @@ void *user_alloc(ThreadState *thr, uptr pc, uptr sz, uptr align) {
return 0;
MBlock *b = new(allocator()->GetMetaData(p)) MBlock;
b->Init(sz, thr->tid, CurrentStackId(thr, pc));
- if (CTX() && CTX()->initialized)
- MemoryRangeImitateWrite(thr, pc, (uptr)p, sz);
+ if (CTX() && CTX()->initialized) {
+ if (thr->ignore_reads_and_writes == 0)
+ MemoryRangeImitateWrite(thr, pc, (uptr)p, sz);
+ else
+ MemoryResetRange(thr, pc, (uptr)p, sz);
+ }
DPrintf("#%d: alloc(%zu) = %p\n", thr->tid, sz, p);
SignalUnsafeCall(thr, pc);
return p;
@@ -134,8 +138,10 @@ void user_free(ThreadState *thr, uptr pc, void *p) {
}
b->ListReset();
}
- if (CTX() && CTX()->initialized && thr->in_rtl == 1)
- MemoryRangeFreed(thr, pc, (uptr)p, b->Size());
+ if (CTX() && CTX()->initialized && thr->in_rtl == 1) {
+ if (thr->ignore_reads_and_writes == 0)
+ MemoryRangeFreed(thr, pc, (uptr)p, b->Size());
+ }
allocator()->Deallocate(&thr->alloc_cache, p);
SignalUnsafeCall(thr, pc);
}