forked from OSchip/llvm-project
[Asan] Accept __lsan_ignore_object for redzone pointer
The check that the pointer inside of the user part of the chunk does not adds any value, but it's the last user of AddrIsInside. I'd like to simplify AsanChunk in followup patches. Reviewed By: morehouse Differential Revision: https://reviews.llvm.org/D87642
This commit is contained in:
parent
a36278c2f8
commit
1d70984fa2
|
@ -162,9 +162,6 @@ class AsanChunk : public ChunkBase {
|
|||
}
|
||||
return reinterpret_cast<void*>(Beg() - RZLog2Size(rz_log));
|
||||
}
|
||||
bool AddrIsInside(uptr addr, bool locked_version = false) {
|
||||
return (addr >= Beg()) && (addr < Beg() + UsedSize(locked_version));
|
||||
}
|
||||
};
|
||||
|
||||
struct QuarantineCallback {
|
||||
|
@ -1172,16 +1169,14 @@ void ForEachChunk(ForEachChunkCallback callback, void *arg) {
|
|||
IgnoreObjectResult IgnoreObjectLocked(const void *p) {
|
||||
uptr addr = reinterpret_cast<uptr>(p);
|
||||
__asan::AsanChunk *m = __asan::instance.GetAsanChunkByAddr(addr);
|
||||
if (!m) return kIgnoreObjectInvalid;
|
||||
if ((atomic_load(&m->chunk_state, memory_order_acquire) ==
|
||||
__asan::CHUNK_ALLOCATED) &&
|
||||
m->AddrIsInside(addr)) {
|
||||
if (m->lsan_tag == kIgnored)
|
||||
return kIgnoreObjectAlreadyIgnored;
|
||||
m->lsan_tag = __lsan::kIgnored;
|
||||
return kIgnoreObjectSuccess;
|
||||
if (!m || (atomic_load(&m->chunk_state, memory_order_acquire) !=
|
||||
__asan::CHUNK_ALLOCATED)) {
|
||||
return kIgnoreObjectInvalid;
|
||||
}
|
||||
return kIgnoreObjectInvalid;
|
||||
if (m->lsan_tag == kIgnored)
|
||||
return kIgnoreObjectAlreadyIgnored;
|
||||
m->lsan_tag = __lsan::kIgnored;
|
||||
return kIgnoreObjectSuccess;
|
||||
}
|
||||
} // namespace __lsan
|
||||
|
||||
|
|
|
@ -5,12 +5,20 @@
|
|||
#include <sanitizer/lsan_interface.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
int *x, *y, *z;
|
||||
|
||||
int main() {
|
||||
int *x = new int;
|
||||
x = new int;
|
||||
__lsan_ignore_object(x);
|
||||
|
||||
{
|
||||
__lsan::ScopedDisabler disabler;
|
||||
double *y = new double;
|
||||
y = new int;
|
||||
}
|
||||
|
||||
z = new int;
|
||||
__lsan_ignore_object(z - 1);
|
||||
|
||||
x = y = z = nullptr;
|
||||
return 0;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue