From b256ac75844a6ce8ca85e7afa5ff38efa136d65e Mon Sep 17 00:00:00 2001 From: Sergey Matveev Date: Tue, 4 Jun 2013 10:39:24 +0000 Subject: [PATCH] [asan] Fix invalid thread registry access when checking if LSan is disabled. llvm-svn: 183218 --- compiler-rt/lib/asan/asan_allocator2.cc | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/compiler-rt/lib/asan/asan_allocator2.cc b/compiler-rt/lib/asan/asan_allocator2.cc index f1302f041937..8dacf67d7987 100644 --- a/compiler-rt/lib/asan/asan_allocator2.cc +++ b/compiler-rt/lib/asan/asan_allocator2.cc @@ -422,8 +422,10 @@ static void *Allocate(uptr size, uptr alignment, StackTrace *stack, uptr fill_size = Min(size, (uptr)fl.max_malloc_fill_size); REAL(memset)(res, fl.malloc_fill_byte, fill_size); } - m->lsan_tag = - t->lsan_disabled() ? __lsan::kSuppressed : __lsan::kDirectlyLeaked; + if (t && t->lsan_disabled()) + m->lsan_tag = __lsan::kSuppressed; + else + m->lsan_tag = __lsan::kDirectlyLeaked; // Must be the last mutation of metadata in this function. atomic_store((atomic_uint8_t *)m, CHUNK_ALLOCATED, memory_order_release); ASAN_MALLOC_HOOK(res, size);