forked from OSchip/llvm-project
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
This commit is contained in:
parent
7ed22a6fa9
commit
d41233e9cf
|
@ -698,7 +698,8 @@ enum : AccessType {
|
||||||
kAccessWrite = 0,
|
kAccessWrite = 0,
|
||||||
kAccessRead = 1 << 0,
|
kAccessRead = 1 << 0,
|
||||||
kAccessAtomic = 1 << 1,
|
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,
|
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;
|
bool is_atomic = typ & kAccessAtomic;
|
||||||
if (typ & kAccessVptr)
|
if (typ & kAccessVptr)
|
||||||
thr->is_vptr_access = true;
|
thr->is_vptr_access = true;
|
||||||
|
if (typ & kAccessFree)
|
||||||
|
thr->is_freeing = true;
|
||||||
MemoryAccess(thr, pc, addr, size_log, is_write, is_atomic);
|
MemoryAccess(thr, pc, addr, size_log, is_write, is_atomic);
|
||||||
if (typ & kAccessVptr)
|
if (typ & kAccessVptr)
|
||||||
thr->is_vptr_access = false;
|
thr->is_vptr_access = false;
|
||||||
|
if (typ & kAccessFree)
|
||||||
|
thr->is_freeing = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
void MemoryResetRange(ThreadState *thr, uptr pc, uptr addr, uptr size);
|
void MemoryResetRange(ThreadState *thr, uptr pc, uptr addr, uptr size);
|
||||||
|
|
|
@ -132,12 +132,8 @@ void MutexDestroy(ThreadState *thr, uptr pc, uptr addr, u32 flagz) {
|
||||||
// Imitate a memory write to catch unlock-destroy races.
|
// Imitate a memory write to catch unlock-destroy races.
|
||||||
// Do this outside of sync mutex, because it can report a race which locks
|
// Do this outside of sync mutex, because it can report a race which locks
|
||||||
// sync mutexes.
|
// sync mutexes.
|
||||||
if (IsAppMem(addr)) {
|
if (IsAppMem(addr))
|
||||||
CHECK(!thr->is_freeing);
|
MemoryAccess(thr, pc, addr, 1, kAccessWrite | kAccessFree);
|
||||||
thr->is_freeing = true;
|
|
||||||
MemoryAccess(thr, pc, addr, 1, kAccessWrite);
|
|
||||||
thr->is_freeing = false;
|
|
||||||
}
|
|
||||||
// s will be destroyed and freed in MetaMap::FreeBlock.
|
// s will be destroyed and freed in MetaMap::FreeBlock.
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue