diff options
author | Kostya Serebryany <kcc@google.com> | 2013-01-28 08:05:47 +0000 |
---|---|---|
committer | Kostya Serebryany <kcc@google.com> | 2013-01-28 08:05:47 +0000 |
commit | 61761f182bf2a7a1dd69b931f4ed7ba85a02f280 (patch) | |
tree | 8cc3060a6c49db5e7a1dd95c4edd9687c5f185c9 /compiler-rt | |
parent | 4ad42359866c319800e0098e99c7292e38113900 (diff) | |
download | bcm5719-llvm-61761f182bf2a7a1dd69b931f4ed7ba85a02f280.tar.gz bcm5719-llvm-61761f182bf2a7a1dd69b931f4ed7ba85a02f280.zip |
[asan] fix a crash in asan stats printing (initialize the allocator in __asan_init)
llvm-svn: 173676
Diffstat (limited to 'compiler-rt')
-rw-r--r-- | compiler-rt/lib/asan/asan_allocator.cc | 2 | ||||
-rw-r--r-- | compiler-rt/lib/asan/asan_allocator.h | 2 | ||||
-rw-r--r-- | compiler-rt/lib/asan/asan_allocator2.cc | 9 | ||||
-rw-r--r-- | compiler-rt/lib/asan/asan_rtl.cc | 2 |
4 files changed, 9 insertions, 6 deletions
diff --git a/compiler-rt/lib/asan/asan_allocator.cc b/compiler-rt/lib/asan/asan_allocator.cc index 370307a89cc..1fe2bbdbf45 100644 --- a/compiler-rt/lib/asan/asan_allocator.cc +++ b/compiler-rt/lib/asan/asan_allocator.cc @@ -688,6 +688,8 @@ void __asan_free_hook(void *ptr) { namespace __asan { +void InitializeAllocator() { } + void PrintInternalAllocatorStats() { } diff --git a/compiler-rt/lib/asan/asan_allocator.h b/compiler-rt/lib/asan/asan_allocator.h index cca24edad81..2de6b982ac7 100644 --- a/compiler-rt/lib/asan/asan_allocator.h +++ b/compiler-rt/lib/asan/asan_allocator.h @@ -42,6 +42,8 @@ enum AllocType { static const uptr kNumberOfSizeClasses = 255; struct AsanChunk; +void InitializeAllocator(); + class AsanChunkView { public: explicit AsanChunkView(AsanChunk *chunk) : chunk_(chunk) {} diff --git a/compiler-rt/lib/asan/asan_allocator2.cc b/compiler-rt/lib/asan/asan_allocator2.cc index 184627a586a..63cb41b4c97 100644 --- a/compiler-rt/lib/asan/asan_allocator2.cc +++ b/compiler-rt/lib/asan/asan_allocator2.cc @@ -295,18 +295,15 @@ struct QuarantineCallback { AllocatorCache *cache_; }; -static void Init() { - static int inited = 0; - if (inited) return; - __asan_init(); - inited = true; // this must happen before any threads are created. +void InitializeAllocator() { allocator.Init(); quarantine.Init((uptr)flags()->quarantine_size, kMaxThreadLocalQuarantine); } static void *Allocate(uptr size, uptr alignment, StackTrace *stack, AllocType alloc_type) { - Init(); + if (!asan_inited) + __asan_init(); CHECK(stack); const uptr min_alignment = SHADOW_GRANULARITY; if (alignment < min_alignment) diff --git a/compiler-rt/lib/asan/asan_rtl.cc b/compiler-rt/lib/asan/asan_rtl.cc index d16f1e37735..2a4adea49f2 100644 --- a/compiler-rt/lib/asan/asan_rtl.cc +++ b/compiler-rt/lib/asan/asan_rtl.cc @@ -426,6 +426,8 @@ void __asan_init() { asanThreadRegistry().GetMain()->ThreadStart(); force_interface_symbols(); // no-op. + InitializeAllocator(); + if (flags()->verbosity) { Report("AddressSanitizer Init done\n"); } |