[asan] Move lsan_disabled out of thread context.
Fix for the case where disabler is used in pthread key destructor.
git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@184553 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/lsan/lsan_allocator.cc b/lib/lsan/lsan_allocator.cc
index 08b8fbd..bf2c2e5 100644
--- a/lib/lsan/lsan_allocator.cc
+++ b/lib/lsan/lsan_allocator.cc
@@ -44,8 +44,6 @@
static Allocator allocator;
static THREADLOCAL AllocatorCache cache;
-// All allocations made while this is > 0 will be treated as non-leaks.
-static THREADLOCAL uptr lsan_disabled;
void InitializeAllocator() {
allocator.Init();
@@ -63,7 +61,7 @@
if (!p) return;
ChunkMetadata *m = Metadata(p);
CHECK(m);
- m->tag = lsan_disabled ? kIgnored : kDirectlyLeaked;
+ m->tag = DisabledInThisThread() ? kIgnored : kDirectlyLeaked;
m->stack_trace_id = StackDepotPut(stack.trace, stack.size);
m->requested_size = size;
atomic_store((atomic_uint8_t*)m, 1, memory_order_relaxed);
@@ -188,8 +186,8 @@
template void ForEachChunk<CollectLeaksCb>(CollectLeaksCb const &callback);
template void ForEachChunk<MarkIndirectlyLeakedCb>(
MarkIndirectlyLeakedCb const &callback);
-template void ForEachChunk<CollectSuppressedCb>(
- CollectSuppressedCb const &callback);
+template void ForEachChunk<CollectIgnoredCb>(
+ CollectIgnoredCb const &callback);
IgnoreObjectResult IgnoreObjectLocked(const void *p) {
void *chunk = allocator.GetBlockBegin(p);
@@ -206,20 +204,3 @@
}
}
} // namespace __lsan
-
-extern "C" {
-SANITIZER_INTERFACE_ATTRIBUTE
-void __lsan_disable() {
- __lsan::lsan_disabled++;
-}
-
-SANITIZER_INTERFACE_ATTRIBUTE
-void __lsan_enable() {
- if (!__lsan::lsan_disabled) {
- Report("Unmatched call to __lsan_enable().\n");
- Die();
- }
- __lsan::lsan_disabled--;
-}
-} // extern "C"
-