[compiler-rt] d41233e - tsan: introduce kAccessFree
Dmitry Vyukov via llvm-commits
llvm-commits at lists.llvm.org
Wed Aug 4 09:03:45 PDT 2021
Author: Dmitry Vyukov
Date: 2021-08-04T18:03:41+02:00
New Revision: d41233e9cf12b85b4f856fe6f4c881211b29534c
URL: https://github.com/llvm/llvm-project/commit/d41233e9cf12b85b4f856fe6f4c881211b29534c
DIFF: https://github.com/llvm/llvm-project/commit/d41233e9cf12b85b4f856fe6f4c881211b29534c.diff
LOG: tsan: introduce kAccessFree
Add kAccessFree memory access flag (similar to kAccessVptr).
In preparation for MemoryAccess refactoring.
Reviewed By: melver
Differential Revision: https://reviews.llvm.org/D107464
Added:
Modified:
compiler-rt/lib/tsan/rtl/tsan_rtl.h
compiler-rt/lib/tsan/rtl/tsan_rtl_mutex.cpp
Removed:
################################################################################
diff --git a/compiler-rt/lib/tsan/rtl/tsan_rtl.h b/compiler-rt/lib/tsan/rtl/tsan_rtl.h
index 483459b7646d..327590456626 100644
--- a/compiler-rt/lib/tsan/rtl/tsan_rtl.h
+++ b/compiler-rt/lib/tsan/rtl/tsan_rtl.h
@@ -698,7 +698,8 @@ enum : AccessType {
kAccessWrite = 0,
kAccessRead = 1 << 0,
kAccessAtomic = 1 << 1,
- kAccessVptr = 1 << 2,
+ kAccessVptr = 1 << 2, // read or write of an object virtual table pointer
+ kAccessFree = 1 << 3, // synthetic memory access during memory freeing
};
void MemoryAccess(ThreadState *thr, uptr pc, uptr addr,
@@ -741,9 +742,13 @@ void MemoryAccess(ThreadState *thr, uptr pc, uptr addr, uptr size,
bool is_atomic = typ & kAccessAtomic;
if (typ & kAccessVptr)
thr->is_vptr_access = true;
+ if (typ & kAccessFree)
+ thr->is_freeing = true;
MemoryAccess(thr, pc, addr, size_log, is_write, is_atomic);
if (typ & kAccessVptr)
thr->is_vptr_access = false;
+ if (typ & kAccessFree)
+ thr->is_freeing = false;
}
void MemoryResetRange(ThreadState *thr, uptr pc, uptr addr, uptr size);
diff --git a/compiler-rt/lib/tsan/rtl/tsan_rtl_mutex.cpp b/compiler-rt/lib/tsan/rtl/tsan_rtl_mutex.cpp
index a3554725c44e..795732475f63 100644
--- a/compiler-rt/lib/tsan/rtl/tsan_rtl_mutex.cpp
+++ b/compiler-rt/lib/tsan/rtl/tsan_rtl_mutex.cpp
@@ -132,12 +132,8 @@ void MutexDestroy(ThreadState *thr, uptr pc, uptr addr, u32 flagz) {
// Imitate a memory write to catch unlock-destroy races.
// Do this outside of sync mutex, because it can report a race which locks
// sync mutexes.
- if (IsAppMem(addr)) {
- CHECK(!thr->is_freeing);
- thr->is_freeing = true;
- MemoryAccess(thr, pc, addr, 1, kAccessWrite);
- thr->is_freeing = false;
- }
+ if (IsAppMem(addr))
+ MemoryAccess(thr, pc, addr, 1, kAccessWrite | kAccessFree);
// s will be destroyed and freed in MetaMap::FreeBlock.
}
More information about the llvm-commits
mailing list