diff options
author | Alexey Samsonov <samsonov@google.com> | 2012-07-09 14:36:04 +0000 |
---|---|---|
committer | Alexey Samsonov <samsonov@google.com> | 2012-07-09 14:36:04 +0000 |
commit | 34efb8e9b9670e0e94ad67e742cc30d9abbb82db (patch) | |
tree | 610a637edc5cf40a79a3608feb97d67e1378cd62 /compiler-rt | |
parent | d7ba69de9050f8f2fc3b7dd4bc491273160af640 (diff) | |
download | bcm5719-llvm-34efb8e9b9670e0e94ad67e742cc30d9abbb82db.tar.gz bcm5719-llvm-34efb8e9b9670e0e94ad67e742cc30d9abbb82db.zip |
[ASan] Use common flags parsing machinery.
llvm-svn: 159933
Diffstat (limited to 'compiler-rt')
-rw-r--r-- | compiler-rt/lib/asan/asan_allocator.cc | 22 | ||||
-rw-r--r-- | compiler-rt/lib/asan/asan_globals.cc | 16 | ||||
-rw-r--r-- | compiler-rt/lib/asan/asan_interceptors.cc | 36 | ||||
-rw-r--r-- | compiler-rt/lib/asan/asan_internal.h | 52 | ||||
-rw-r--r-- | compiler-rt/lib/asan/asan_linux.cc | 2 | ||||
-rw-r--r-- | compiler-rt/lib/asan/asan_mac.cc | 26 | ||||
-rw-r--r-- | compiler-rt/lib/asan/asan_malloc_mac.cc | 8 | ||||
-rw-r--r-- | compiler-rt/lib/asan/asan_poisoning.cc | 8 | ||||
-rw-r--r-- | compiler-rt/lib/asan/asan_posix.cc | 8 | ||||
-rw-r--r-- | compiler-rt/lib/asan/asan_rtl.cc | 242 | ||||
-rw-r--r-- | compiler-rt/lib/asan/asan_stack.cc | 2 | ||||
-rw-r--r-- | compiler-rt/lib/asan/asan_stack.h | 4 | ||||
-rw-r--r-- | compiler-rt/lib/asan/asan_thread.cc | 10 | ||||
-rw-r--r-- | compiler-rt/lib/asan/asan_thread_registry.cc | 2 |
14 files changed, 210 insertions, 228 deletions
diff --git a/compiler-rt/lib/asan/asan_allocator.cc b/compiler-rt/lib/asan/asan_allocator.cc index acd466ec95d..0e8530c0516 100644 --- a/compiler-rt/lib/asan/asan_allocator.cc +++ b/compiler-rt/lib/asan/asan_allocator.cc @@ -42,7 +42,7 @@ namespace __asan { -#define REDZONE FLAG_redzone +#define REDZONE (flags()->redzone) static const uptr kMinAllocSize = REDZONE * 2; static const u64 kMaxAvailableRam = 128ULL << 30; // 128G static const uptr kMaxThreadLocalQuarantine = 1 << 20; // 1M @@ -134,7 +134,7 @@ static u8 *MmapNewPagesAndPoisonShadow(uptr size) { CHECK(IsAligned(size, kPageSize)); u8 *res = (u8*)MmapOrDie(size, __FUNCTION__); PoisonShadow((uptr)res, size, kAsanHeapLeftRedzoneMagic); - if (FLAG_debug) { + if (flags()->debug) { Printf("ASAN_MMAP: [%p, %p)\n", res, res + size); } return res; @@ -186,7 +186,7 @@ struct AsanChunk: public ChunkBase { return (u32*)((uptr)this + sizeof(ChunkBase)); } u32 *compressed_free_stack() { - return (u32*)((uptr)this + Max(REDZONE, (uptr)sizeof(ChunkBase))); + return (u32*)((uptr)this + Max((uptr)REDZONE, (uptr)sizeof(ChunkBase))); } // The left redzone after the ChunkBase is given to the alloc stack trace. @@ -339,12 +339,12 @@ class MallocInfo { void SwallowThreadLocalMallocStorage(AsanThreadLocalMallocStorage *x, bool eat_free_lists) { - CHECK(FLAG_quarantine_size > 0); + CHECK(flags()->quarantine_size > 0); ScopedLock lock(&mu_); AsanChunkFifoList *q = &x->quarantine_; if (q->size() > 0) { quarantine_.PushList(q); - while (quarantine_.size() > FLAG_quarantine_size) { + while (quarantine_.size() > flags()->quarantine_size) { QuarantinePop(); } } @@ -644,7 +644,7 @@ static u8 *Allocate(uptr alignment, uptr size, AsanStackTrace *stack) { CHECK(size_to_allocate >= needed_size); CHECK(IsAligned(size_to_allocate, REDZONE)); - if (FLAG_v >= 3) { + if (flags()->verbosity >= 3) { Printf("Allocate align: %zu size: %zu class: %u real: %zu\n", alignment, size, size_class, size_to_allocate); } @@ -704,7 +704,7 @@ static u8 *Allocate(uptr alignment, uptr size, AsanStackTrace *stack) { PoisonHeapPartialRightRedzone(addr + rounded_size - REDZONE, size & (REDZONE - 1)); } - if (size <= FLAG_max_malloc_fill_size) { + if (size <= flags()->max_malloc_fill_size) { REAL(memset)((void*)addr, 0, rounded_size); } return (u8*)addr; @@ -714,7 +714,7 @@ static void Deallocate(u8 *ptr, AsanStackTrace *stack) { if (!ptr) return; CHECK(stack); - if (FLAG_debug) { + if (flags()->debug) { CHECK(malloc_info.FindPageGroup((uptr)ptr)); } @@ -882,7 +882,7 @@ uptr asan_malloc_usable_size(void *ptr, AsanStackTrace *stack) { CHECK(stack); if (ptr == 0) return 0; uptr usable_size = malloc_info.AllocationSize((uptr)ptr); - if (FLAG_check_malloc_usable_size && (usable_size == 0)) { + if (flags()->check_malloc_usable_size && (usable_size == 0)) { AsanReport("ERROR: AddressSanitizer attempting to call " "malloc_usable_size() for pointer which is " "not owned: %p\n", ptr); @@ -1055,7 +1055,7 @@ void FakeStack::OnFree(uptr ptr, uptr size, uptr real_stack) { using namespace __asan; // NOLINT uptr __asan_stack_malloc(uptr size, uptr real_stack) { - if (!FLAG_use_fake_stack) return real_stack; + if (!flags()->use_fake_stack) return real_stack; AsanThread *t = asanThreadRegistry().GetCurrent(); if (!t) { // TSD is gone, use the real stack. @@ -1067,7 +1067,7 @@ uptr __asan_stack_malloc(uptr size, uptr real_stack) { } void __asan_stack_free(uptr ptr, uptr size, uptr real_stack) { - if (!FLAG_use_fake_stack) return; + if (!flags()->use_fake_stack) return; if (ptr != real_stack) { FakeStack::OnFree(ptr, size, real_stack); } diff --git a/compiler-rt/lib/asan/asan_globals.cc b/compiler-rt/lib/asan/asan_globals.cc index 1309e449cc3..f8c4040b8e8 100644 --- a/compiler-rt/lib/asan/asan_globals.cc +++ b/compiler-rt/lib/asan/asan_globals.cc @@ -88,12 +88,12 @@ bool DescribeAddrIfMyRedZone(const Global &g, uptr addr) { bool DescribeAddrIfGlobal(uptr addr) { - if (!FLAG_report_globals) return false; + if (!flags()->report_globals) return false; ScopedLock lock(&mu_for_globals); bool res = false; for (ListOfGlobals *l = list_of_globals; l; l = l->next) { const Global &g = *l->g; - if (FLAG_report_globals >= 2) + if (flags()->report_globals >= 2) AsanPrintf("Search Global: beg=%p size=%zu name=%s\n", (void*)g.beg, g.size, (char*)g.name); res |= DescribeAddrIfMyRedZone(g, addr); @@ -106,7 +106,7 @@ bool DescribeAddrIfGlobal(uptr addr) { // so we store the globals in a map. static void RegisterGlobal(const Global *g) { CHECK(asan_inited); - CHECK(FLAG_report_globals); + CHECK(flags()->report_globals); CHECK(AddrIsInMem(g->beg)); CHECK(AddrIsAlignedByGranularity(g->beg)); CHECK(AddrIsAlignedByGranularity(g->size_with_redzone)); @@ -116,14 +116,14 @@ static void RegisterGlobal(const Global *g) { l->g = g; l->next = list_of_globals; list_of_globals = l; - if (FLAG_report_globals >= 2) + if (flags()->report_globals >= 2) Report("Added Global: beg=%p size=%zu name=%s\n", (void*)g->beg, g->size, g->name); } static void UnregisterGlobal(const Global *g) { CHECK(asan_inited); - CHECK(FLAG_report_globals); + CHECK(flags()->report_globals); CHECK(AddrIsInMem(g->beg)); CHECK(AddrIsAlignedByGranularity(g->beg)); CHECK(AddrIsAlignedByGranularity(g->size_with_redzone)); @@ -141,7 +141,7 @@ using namespace __asan; // NOLINT // Register one global with a default redzone. void __asan_register_global(uptr addr, uptr size, const char *name) { - if (!FLAG_report_globals) return; + if (!flags()->report_globals) return; ScopedLock lock(&mu_for_globals); Global *g = (Global *)allocator_for_globals.Allocate(sizeof(Global)); g->beg = addr; @@ -153,7 +153,7 @@ void __asan_register_global(uptr addr, uptr size, // Register an array of globals. void __asan_register_globals(__asan_global *globals, uptr n) { - if (!FLAG_report_globals) return; + if (!flags()->report_globals) return; ScopedLock lock(&mu_for_globals); for (uptr i = 0; i < n; i++) { RegisterGlobal(&globals[i]); @@ -163,7 +163,7 @@ void __asan_register_globals(__asan_global *globals, uptr n) { // Unregister an array of globals. // We must do it when a shared objects gets dlclosed. void __asan_unregister_globals(__asan_global *globals, uptr n) { - if (!FLAG_report_globals) return; + if (!flags()->report_globals) return; ScopedLock lock(&mu_for_globals); for (uptr i = 0; i < n; i++) { UnregisterGlobal(&globals[i]); diff --git a/compiler-rt/lib/asan/asan_interceptors.cc b/compiler-rt/lib/asan/asan_interceptors.cc index 5becad3cca7..57ee58286fd 100644 --- a/compiler-rt/lib/asan/asan_interceptors.cc +++ b/compiler-rt/lib/asan/asan_interceptors.cc @@ -321,7 +321,7 @@ INTERCEPTOR(void*, memcpy, void *to, const void *from, uptr size) { return REAL(memcpy)(to, from, size); } ENSURE_ASAN_INITED(); - if (FLAG_replace_intrin) { + if (flags()->replace_intrin) { if (to != from) { // We do not treat memcpy with to==from as a bug. // See http://llvm.org/bugs/show_bug.cgi?id=11763. @@ -338,7 +338,7 @@ INTERCEPTOR(void*, memmove, void *to, const void *from, uptr size) { return REAL(memmove)(to, from, size); } ENSURE_ASAN_INITED(); - if (FLAG_replace_intrin) { + if (flags()->replace_intrin) { ASAN_WRITE_RANGE(from, size); ASAN_READ_RANGE(to, size); } @@ -351,7 +351,7 @@ INTERCEPTOR(void*, memset, void *block, int c, uptr size) { return REAL(memset)(block, c, size); } ENSURE_ASAN_INITED(); - if (FLAG_replace_intrin) { + if (flags()->replace_intrin) { ASAN_WRITE_RANGE(block, size); } return REAL(memset)(block, c, size); @@ -360,7 +360,7 @@ INTERCEPTOR(void*, memset, void *block, int c, uptr size) { INTERCEPTOR(char*, strchr, const char *str, int c) { ENSURE_ASAN_INITED(); char *result = REAL(strchr)(str, c); - if (FLAG_replace_str) { + if (flags()->replace_str) { uptr bytes_read = (result ? result - str : REAL(strlen)(str)) + 1; ASAN_READ_RANGE(str, bytes_read); } @@ -390,7 +390,7 @@ INTERCEPTOR(int, strcasecmp, const char *s1, const char *s2) { INTERCEPTOR(char*, strcat, char *to, const char *from) { // NOLINT ENSURE_ASAN_INITED(); - if (FLAG_replace_str) { + if (flags()->replace_str) { uptr from_length = REAL(strlen)(from); ASAN_READ_RANGE(from, from_length + 1); if (from_length > 0) { @@ -405,7 +405,7 @@ INTERCEPTOR(char*, strcat, char *to, const char *from) { // NOLINT INTERCEPTOR(char*, strncat, char *to, const char *from, uptr size) { ENSURE_ASAN_INITED(); - if (FLAG_replace_str && size > 0) { + if (flags()->replace_str && size > 0) { uptr from_length = MaybeRealStrnlen(from, size); ASAN_READ_RANGE(from, Min(size, from_length + 1)); uptr to_length = REAL(strlen)(to); @@ -442,7 +442,7 @@ INTERCEPTOR(char*, strcpy, char *to, const char *from) { // NOLINT return REAL(strcpy)(to, from); // NOLINT } ENSURE_ASAN_INITED(); - if (FLAG_replace_str) { + if (flags()->replace_str) { uptr from_size = REAL(strlen)(from) + 1; CHECK_RANGES_OVERLAP("strcpy", to, from_size, from, from_size); ASAN_READ_RANGE(from, from_size); @@ -453,7 +453,7 @@ INTERCEPTOR(char*, strcpy, char *to, const char *from) { // NOLINT INTERCEPTOR(char*, strdup, const char *s) { ENSURE_ASAN_INITED(); - if (FLAG_replace_str) { + if (flags()->replace_str) { uptr length = REAL(strlen)(s); ASAN_READ_RANGE(s, length + 1); } @@ -468,7 +468,7 @@ INTERCEPTOR(uptr, strlen, const char *s) { } ENSURE_ASAN_INITED(); uptr length = REAL(strlen)(s); - if (FLAG_replace_str) { + if (flags()->replace_str) { ASAN_READ_RANGE(s, length + 1); } return length; @@ -508,7 +508,7 @@ INTERCEPTOR(int, strncmp, const char *s1, const char *s2, uptr size) { INTERCEPTOR(char*, strncpy, char *to, const char *from, uptr size) { ENSURE_ASAN_INITED(); - if (FLAG_replace_str) { + if (flags()->replace_str) { uptr from_size = Min(size, MaybeRealStrnlen(from, size) + 1); CHECK_RANGES_OVERLAP("strncpy", to, from_size, from, from_size); ASAN_READ_RANGE(from, from_size); @@ -521,7 +521,7 @@ INTERCEPTOR(char*, strncpy, char *to, const char *from, uptr size) { INTERCEPTOR(uptr, strnlen, const char *s, uptr maxlen) { ENSURE_ASAN_INITED(); uptr length = REAL(strnlen)(s, maxlen); - if (FLAG_replace_str) { + if (flags()->replace_str) { ASAN_READ_RANGE(s, Min(length + 1, maxlen)); } return length; @@ -548,7 +548,7 @@ static inline void FixRealStrtolEndptr(const char *nptr, char **endptr) { INTERCEPTOR(long, strtol, const char *nptr, // NOLINT char **endptr, int base) { ENSURE_ASAN_INITED(); - if (!FLAG_replace_str) { + if (!flags()->replace_str) { return REAL(strtol)(nptr, endptr, base); } char *real_endptr; @@ -565,7 +565,7 @@ INTERCEPTOR(long, strtol, const char *nptr, // NOLINT INTERCEPTOR(int, atoi, const char *nptr) { ENSURE_ASAN_INITED(); - if (!FLAG_replace_str) { + if (!flags()->replace_str) { return REAL(atoi)(nptr); } char *real_endptr; @@ -581,7 +581,7 @@ INTERCEPTOR(int, atoi, const char *nptr) { INTERCEPTOR(long, atol, const char *nptr) { // NOLINT ENSURE_ASAN_INITED(); - if (!FLAG_replace_str) { + if (!flags()->replace_str) { return REAL(atol)(nptr); } char *real_endptr; @@ -595,7 +595,7 @@ INTERCEPTOR(long, atol, const char *nptr) { // NOLINT INTERCEPTOR(long long, strtoll, const char *nptr, // NOLINT char **endptr, int base) { ENSURE_ASAN_INITED(); - if (!FLAG_replace_str) { + if (!flags()->replace_str) { return REAL(strtoll)(nptr, endptr, base); } char *real_endptr; @@ -615,7 +615,7 @@ INTERCEPTOR(long long, strtoll, const char *nptr, // NOLINT INTERCEPTOR(long long, atoll, const char *nptr) { // NOLINT ENSURE_ASAN_INITED(); - if (!FLAG_replace_str) { + if (!flags()->replace_str) { return REAL(atoll)(nptr); } char *real_endptr; @@ -627,7 +627,7 @@ INTERCEPTOR(long long, atoll, const char *nptr) { // NOLINT #endif // ASAN_INTERCEPT_ATOLL_AND_STRTOLL #define ASAN_INTERCEPT_FUNC(name) do { \ - if (!INTERCEPT_FUNCTION(name) && FLAG_v > 0) \ + if (!INTERCEPT_FUNCTION(name) && flags()->verbosity > 0) \ Report("AddressSanitizer: failed to intercept '" #name "'\n"); \ } while (0) @@ -731,7 +731,7 @@ void InitializeAsanInterceptors() { InitializeMacInterceptors(); #endif - if (FLAG_v > 0) { + if (flags()->verbosity > 0) { Report("AddressSanitizer: libc interceptors initialized\n"); } } diff --git a/compiler-rt/lib/asan/asan_internal.h b/compiler-rt/lib/asan/asan_internal.h index 2e6f5a13388..2ee1b12317e 100644 --- a/compiler-rt/lib/asan/asan_internal.h +++ b/compiler-rt/lib/asan/asan_internal.h @@ -136,30 +136,34 @@ bool PlatformHasDifferentMemcpyAndMemmove(); # define PLATFORM_HAS_DIFFERENT_MEMCPY_AND_MEMMOVE true #endif // __APPLE__ -extern uptr FLAG_quarantine_size; -extern s64 FLAG_demangle; -extern bool FLAG_symbolize; -extern s64 FLAG_v; -extern uptr FLAG_redzone; -extern s64 FLAG_debug; -extern bool FLAG_poison_shadow; -extern s64 FLAG_report_globals; -extern uptr FLAG_malloc_context_size; -extern bool FLAG_replace_str; -extern bool FLAG_replace_intrin; -extern bool FLAG_replace_cfallocator; -extern bool FLAG_mac_ignore_invalid_free; -extern bool FLAG_fast_unwind; -extern bool FLAG_use_fake_stack; -extern uptr FLAG_max_malloc_fill_size; -extern s64 FLAG_exitcode; -extern bool FLAG_allow_user_poisoning; -extern s64 FLAG_sleep_before_dying; -extern bool FLAG_handle_segv; -extern bool FLAG_use_sigaltstack; -extern bool FLAG_check_malloc_usable_size; -extern bool FLAG_unmap_shadow_on_exit; -extern bool FLAG_abort_on_error; +struct Flags { + int quarantine_size; + bool symbolize; + int verbosity; + int redzone; + int debug; + bool poison_shadow; + int report_globals; + int malloc_context_size; + bool replace_str; + bool replace_intrin; + bool replace_cfallocator; + bool mac_ignore_invalid_free; + bool use_fake_stack; + int max_malloc_fill_size; + int exitcode; + bool allow_user_poisoning; + int sleep_before_dying; + bool handle_segv; + bool use_sigaltstack; + bool check_malloc_usable_size; + bool unmap_shadow_on_exit; + bool abort_on_error; + bool atexit; + bool disable_core; +}; +Flags *flags(); +void InitializeFlags(Flags *f, const char *env); extern int asan_inited; // Used to avoid infinite recursion in __asan_init(). diff --git a/compiler-rt/lib/asan/asan_linux.cc b/compiler-rt/lib/asan/asan_linux.cc index 2c01da27ead..0bb2bf4ad9e 100644 --- a/compiler-rt/lib/asan/asan_linux.cc +++ b/compiler-rt/lib/asan/asan_linux.cc @@ -69,7 +69,7 @@ void GetPcSpBp(void *context, uptr *pc, uptr *sp, uptr *bp) { } bool AsanInterceptsSignal(int signum) { - return signum == SIGSEGV && FLAG_handle_segv; + return signum == SIGSEGV && flags()->handle_segv; } AsanLock::AsanLock(LinkerInitialized) { diff --git a/compiler-rt/lib/asan/asan_mac.cc b/compiler-rt/lib/asan/asan_mac.cc index b219e0ad4ac..3527d9a0b0d 100644 --- a/compiler-rt/lib/asan/asan_mac.cc +++ b/compiler-rt/lib/asan/asan_mac.cc @@ -89,7 +89,7 @@ void *AsanDoesNotSupportStaticLinkage() { } bool AsanInterceptsSignal(int signum) { - return (signum == SIGSEGV || signum == SIGBUS) && FLAG_handle_segv; + return (signum == SIGSEGV || signum == SIGBUS) && flags()->handle_segv; } AsanLock::AsanLock(LinkerInitialized) { @@ -149,7 +149,7 @@ mach_error_t __interception_allocate_island(void **ptr, if (island_allocator_pos != (void*)kIslandBeg) { return KERN_NO_SPACE; } - if (FLAG_v) { + if (flags()->verbosity) { Report("Mapped pages %p--%p for branch islands.\n", (void*)kIslandBeg, (void*)kIslandEnd); } @@ -158,7 +158,7 @@ mach_error_t __interception_allocate_island(void **ptr, }; *ptr = island_allocator_pos; island_allocator_pos = (char*)island_allocator_pos + kPageSize; - if (FLAG_v) { + if (flags()->verbosity) { Report("Branch island allocated at %p\n", *ptr); } return err_none; @@ -241,7 +241,7 @@ extern "C" void asan_dispatch_call_block_and_release(void *block) { GET_STACK_TRACE_HERE(kStackTraceMax); asan_block_context_t *context = (asan_block_context_t*)block; - if (FLAG_v >= 2) { + if (flags()->verbosity >= 2) { Report("asan_dispatch_call_block_and_release(): " "context: %p, pthread_self: %p\n", block, pthread_self()); @@ -280,7 +280,7 @@ INTERCEPTOR(void, dispatch_async_f, dispatch_queue_t dq, void *ctxt, dispatch_function_t func) { GET_STACK_TRACE_HERE(kStackTraceMax); asan_block_context_t *asan_ctxt = alloc_asan_context(ctxt, func, &stack); - if (FLAG_v >= 2) { + if (flags()->verbosity >= 2) { Report("dispatch_async_f(): context: %p, pthread_self: %p\n", asan_ctxt, pthread_self()); PRINT_CURRENT_STACK(); @@ -293,7 +293,7 @@ INTERCEPTOR(void, dispatch_sync_f, dispatch_queue_t dq, void *ctxt, dispatch_function_t func) { GET_STACK_TRACE_HERE(kStackTraceMax); asan_block_context_t *asan_ctxt = alloc_asan_context(ctxt, func, &stack); - if (FLAG_v >= 2) { + if (flags()->verbosity >= 2) { Report("dispatch_sync_f(): context: %p, pthread_self: %p\n", asan_ctxt, pthread_self()); PRINT_CURRENT_STACK(); @@ -307,7 +307,7 @@ INTERCEPTOR(void, dispatch_after_f, dispatch_time_t when, dispatch_function_t func) { GET_STACK_TRACE_HERE(kStackTraceMax); asan_block_context_t *asan_ctxt = alloc_asan_context(ctxt, func, &stack); - if (FLAG_v >= 2) { + if (flags()->verbosity >= 2) { Report("dispatch_after_f: %p\n", asan_ctxt); PRINT_CURRENT_STACK(); } @@ -319,7 +319,7 @@ INTERCEPTOR(void, dispatch_barrier_async_f, dispatch_queue_t dq, void *ctxt, dispatch_function_t func) { GET_STACK_TRACE_HERE(kStackTraceMax); asan_block_context_t *asan_ctxt = alloc_asan_context(ctxt, func, &stack); - if (FLAG_v >= 2) { + if (flags()->verbosity >= 2) { Report("dispatch_barrier_async_f(): context: %p, pthread_self: %p\n", asan_ctxt, pthread_self()); PRINT_CURRENT_STACK(); @@ -333,7 +333,7 @@ INTERCEPTOR(void, dispatch_group_async_f, dispatch_group_t group, dispatch_function_t func) { GET_STACK_TRACE_HERE(kStackTraceMax); asan_block_context_t *asan_ctxt = alloc_asan_context(ctxt, func, &stack); - if (FLAG_v >= 2) { + if (flags()->verbosity >= 2) { Report("dispatch_group_async_f(): context: %p, pthread_self: %p\n", asan_ctxt, pthread_self()); PRINT_CURRENT_STACK(); @@ -350,7 +350,7 @@ INTERCEPTOR(void, dispatch_group_async_f, dispatch_group_t group, // libdispatch API. extern "C" void *wrap_workitem_func(void *arg) { - if (FLAG_v >= 2) { + if (flags()->verbosity >= 2) { Report("wrap_workitem_func: %p, pthread_self: %p\n", arg, pthread_self()); } asan_block_context_t *ctxt = (asan_block_context_t*)arg; @@ -370,7 +370,7 @@ INTERCEPTOR(int, pthread_workqueue_additem_np, pthread_workqueue_t workq, asan_ctxt->block = workitem_arg; asan_ctxt->func = (dispatch_function_t)workitem_func; asan_ctxt->parent_tid = asanThreadRegistry().GetCurrentTidOrInvalid(); - if (FLAG_v >= 2) { + if (flags()->verbosity >= 2) { Report("pthread_workqueue_additem_np: %p\n", asan_ctxt); PRINT_CURRENT_STACK(); } @@ -415,7 +415,7 @@ void InitializeMacInterceptors() { // We don't need to intercept pthread_workqueue_additem_np() to support the // libdispatch API, but it helps us to debug the unsupported functions. Let's // intercept it only during verbose runs. - if (FLAG_v >= 2) { + if (flags()->verbosity >= 2) { CHECK(INTERCEPT_FUNCTION(pthread_workqueue_additem_np)); } // Normally CFStringCreateCopy should not copy constant CF strings. @@ -429,7 +429,7 @@ void InitializeMacInterceptors() { // Some of the library functions call free() directly, so we have to // intercept it. CHECK(INTERCEPT_FUNCTION(free)); - if (FLAG_replace_cfallocator) { + if (flags()->replace_cfallocator) { CHECK(INTERCEPT_FUNCTION(__CFInitialize)); } } diff --git a/compiler-rt/lib/asan/asan_malloc_mac.cc b/compiler-rt/lib/asan/asan_malloc_mac.cc index 1626ebebbcb..fc9adff491c 100644 --- a/compiler-rt/lib/asan/asan_malloc_mac.cc +++ b/compiler-rt/lib/asan/asan_malloc_mac.cc @@ -65,7 +65,7 @@ INTERCEPTOR(void, free, void *ptr) { malloc_zone_free(zone, ptr); #endif } else { - if (FLAG_replace_cfallocator) { + if (flags()->replace_cfallocator) { // Make sure we're not hitting the previous page. This may be incorrect // if ASan's malloc returns an address ending with 0xFF8, which will be // then padded to a page boundary with a CFAllocatorRef. @@ -95,7 +95,7 @@ namespace __asan { // See http://code.google.com/p/address-sanitizer/issues/detail?id=87 // and http://opensource.apple.com/source/CF/CF-550.43/CFRuntime.c INTERCEPTOR(void, __CFInitialize) { - CHECK(FLAG_replace_cfallocator); + CHECK(flags()->replace_cfallocator); CHECK(asan_inited); REAL(__CFInitialize)(); if (!cf_asan) ReplaceCFAllocator(); @@ -169,7 +169,7 @@ void print_zone_for_ptr(void *ptr) { void ALWAYS_INLINE free_common(void *context, void *ptr) { if (!ptr) return; - if (!FLAG_mac_ignore_invalid_free || asan_mz_size(ptr)) { + if (!flags()->mac_ignore_invalid_free || asan_mz_size(ptr)) { GET_STACK_TRACE_HERE_FOR_FREE(ptr); asan_free(ptr, &stack); } else { @@ -403,7 +403,7 @@ void ReplaceSystemMalloc() { // Make sure the default allocator was replaced. CHECK(malloc_default_zone() == &asan_zone); - if (FLAG_replace_cfallocator) { + if (flags()->replace_cfallocator) { // If __CFInitialize() hasn't been called yet, cf_asan will be created and // installed as the default allocator after __CFInitialize() finishes (see // the interceptor for __CFInitialize() above). Otherwise install cf_asan diff --git a/compiler-rt/lib/asan/asan_poisoning.cc b/compiler-rt/lib/asan/asan_poisoning.cc index 9958721484d..3b9d9f6795c 100644 --- a/compiler-rt/lib/asan/asan_poisoning.cc +++ b/compiler-rt/lib/asan/asan_poisoning.cc @@ -75,10 +75,10 @@ using namespace __asan; // NOLINT // * if user asks to unpoison region [left, right), the program unpoisons // at most [AlignDown(left), right). void __asan_poison_memory_region(void const volatile *addr, uptr size) { - if (!FLAG_allow_user_poisoning || size == 0) return; + if (!flags()->allow_user_poisoning || size == 0) return; uptr beg_addr = (uptr)addr; uptr end_addr = beg_addr + size; - if (FLAG_v >= 1) { + if (flags()->verbosity >= 1) { Printf("Trying to poison memory region [%p, %p)\n", (void*)beg_addr, (void*)end_addr); } @@ -117,10 +117,10 @@ void __asan_poison_memory_region(void const volatile *addr, uptr size) { } void __asan_unpoison_memory_region(void const volatile *addr, uptr size) { - if (!FLAG_allow_user_poisoning || size == 0) return; + if (!flags()->allow_user_poisoning || size == 0) return; uptr beg_addr = (uptr)addr; uptr end_addr = beg_addr + size; - if (FLAG_v >= 1) { + if (flags()->verbosity >= 1) { Printf("Trying to unpoison memory region [%p, %p)\n", (void*)beg_addr, (void*)end_addr); } diff --git a/compiler-rt/lib/asan/asan_posix.cc b/compiler-rt/lib/asan/asan_posix.cc index 3bf68b148ad..061bb193034 100644 --- a/compiler-rt/lib/asan/asan_posix.cc +++ b/compiler-rt/lib/asan/asan_posix.cc @@ -40,9 +40,9 @@ static void MaybeInstallSigaction(int signum, REAL(memset)(&sigact, 0, sizeof(sigact)); sigact.sa_sigaction = handler; sigact.sa_flags = SA_SIGINFO; - if (FLAG_use_sigaltstack) sigact.sa_flags |= SA_ONSTACK; + if (flags()->use_sigaltstack) sigact.sa_flags |= SA_ONSTACK; CHECK(0 == REAL(sigaction)(signum, &sigact, 0)); - if (FLAG_v >= 1) { + if (flags()->verbosity >= 1) { Report("Installed the sigaction for signal %d\n", signum); } } @@ -76,7 +76,7 @@ void SetAlternateSignalStack() { altstack.ss_flags = 0; altstack.ss_size = kAltStackSize; CHECK(0 == sigaltstack(&altstack, 0)); - if (FLAG_v > 0) { + if (flags()->verbosity > 0) { Report("Alternative stack for T%d set: [%p,%p)\n", asanThreadRegistry().GetCurrentTidOrInvalid(), altstack.ss_sp, (char*)altstack.ss_sp + altstack.ss_size); @@ -96,7 +96,7 @@ void InstallSignalHandlers() { // Set the alternate signal stack for the main thread. // This will cause SetAlternateSignalStack to be called twice, but the stack // will be actually set only once. - if (FLAG_use_sigaltstack) SetAlternateSignalStack(); + if (flags()->use_sigaltstack) SetAlternateSignalStack(); MaybeInstallSigaction(SIGSEGV, ASAN_OnSIGSEGV); MaybeInstallSigaction(SIGBUS, ASAN_OnSIGSEGV); } diff --git a/compiler-rt/lib/asan/asan_rtl.cc b/compiler-rt/lib/asan/asan_rtl.cc index 616266cf68c..89f46b1ef86 100644 --- a/compiler-rt/lib/asan/asan_rtl.cc +++ b/compiler-rt/lib/asan/asan_rtl.cc @@ -22,6 +22,7 @@ #include "asan_thread.h" #include "asan_thread_registry.h" #include "sanitizer_common/sanitizer_atomic.h" +#include "sanitizer_common/sanitizer_flags.h" #include "sanitizer_common/sanitizer_libc.h" namespace __sanitizer { @@ -33,17 +34,17 @@ void Die() { // Don't die twice - run a busy loop. while (1) { } } - if (FLAG_sleep_before_dying) { - Report("Sleeping for %zd second(s)\n", FLAG_sleep_before_dying); - SleepForSeconds(FLAG_sleep_before_dying); + if (flags()->sleep_before_dying) { + Report("Sleeping for %zd second(s)\n", flags()->sleep_before_dying); + SleepForSeconds(flags()->sleep_before_dying); } - if (FLAG_unmap_shadow_on_exit) + if (flags()->unmap_shadow_on_exit) UnmapOrDie((void*)kLowShadowBeg, kHighShadowEnd - kLowShadowBeg); if (death_callback) death_callback(); - if (FLAG_abort_on_error) + if (flags()->abort_on_error) Abort(); - Exit(FLAG_exitcode); + Exit(flags()->exitcode); } void CheckFailed(const char *file, int line, const char *cond, u64 v1, u64 v2) { @@ -60,31 +61,97 @@ namespace __asan { // -------------------------- Flags ------------------------- {{{1 static const uptr kMallocContextSize = 30; -uptr FLAG_malloc_context_size = kMallocContextSize; -uptr FLAG_max_malloc_fill_size = 0; -s64 FLAG_v = 0; -uptr FLAG_redzone = (ASAN_LOW_MEMORY) ? 64 : 128; // power of two, >= 32 -uptr FLAG_quarantine_size = (ASAN_LOW_MEMORY) ? 1UL << 24 : 1UL << 28; -static s64 FLAG_atexit = 0; -bool FLAG_poison_shadow = 1; -s64 FLAG_report_globals = 1; -bool FLAG_handle_segv = ASAN_NEEDS_SEGV; -bool FLAG_use_sigaltstack = 0; -bool FLAG_symbolize = 0; -s64 FLAG_demangle = 1; -s64 FLAG_debug = 0; -bool FLAG_replace_cfallocator = 1; // Used on Mac only. -bool FLAG_mac_ignore_invalid_free = 0; // Used on Mac only. -bool FLAG_replace_str = 1; -bool FLAG_replace_intrin = 1; -bool FLAG_use_fake_stack = 1; -s64 FLAG_exitcode = ASAN_DEFAULT_FAILURE_EXITCODE; -bool FLAG_allow_user_poisoning = 1; -s64 FLAG_sleep_before_dying = 0; -bool FLAG_abort_on_error = 0; -bool FLAG_unmap_shadow_on_exit = 0; -bool FLAG_disable_core = __WORDSIZE == 64; -bool FLAG_check_malloc_usable_size = 1; +static Flags asan_flags; + +Flags *flags() { + return &asan_flags; +} + +// Can be overriden in frontend. +void WEAK OverrideFlags(Flags *f) { + (void)f; +} + +static void ParseFlagsFromString(Flags *f, const char *str) { + ParseFlag(str, &f->quarantine_size, "quarantine_size"); + ParseFlag(str, &f->symbolize, "symbolize"); + ParseFlag(str, &f->verbosity, "verbosity"); + ParseFlag(str, &f->redzone, "redzone"); + CHECK(f->redzone >= 16); + CHECK(IsPowerOfTwo(f->redzone)); + + ParseFlag(str, &f->debug, "debug"); + ParseFlag(str, &f->poison_shadow, "poison_shadow"); + ParseFlag(str, &f->report_globals, "report_globals"); + ParseFlag(str, &f->malloc_context_size, "malloc_context_size"); + CHECK(f->malloc_context_size <= kMallocContextSize); + + ParseFlag(str, &f->replace_str, "replace_str"); + ParseFlag(str, &f->replace_intrin, "replace_intrin"); + ParseFlag(str, &f->replace_cfallocator, "replace_cfallocator"); + ParseFlag(str, &f->mac_ignore_invalid_free, "mac_ignore_invalid_free"); + ParseFlag(str, &f->use_fake_stack, "use_fake_stack"); + ParseFlag(str, &f->max_malloc_fill_size, "max_malloc_fill_size"); + ParseFlag(str, &f->exitcode, "exitcode"); + ParseFlag(str, &f->allow_user_poisoning, "allow_user_poisoning"); + ParseFlag(str, &f->sleep_before_dying, "sleep_before_dying"); + ParseFlag(str, &f->handle_segv, "handle_segv"); + ParseFlag(str, &f->use_sigaltstack, "use_sigaltstack"); + // Allow the users to work around the bug in Nvidia drivers prior to 295.*. + ParseFlag(str, &f->check_malloc_usable_size, "check_malloc_usable_size"); + ParseFlag(str, &f->unmap_shadow_on_exit, "unmap_shadow_on_exit"); + ParseFlag(str, &f->abort_on_error, "abort_on_error"); + ParseFlag(str, &f->atexit, "atexit"); + // By default, disable core dumper on 64-bit -- + // it makes little sense to dump 16T+ core. + ParseFlag(str, &f->disable_core, "disable_core"); +} + +void InitializeFlags(Flags *f, const char *env) { + internal_memset(f, 0, sizeof(*f)); + + f->quarantine_size = (ASAN_LOW_MEMORY) ? 1UL << 24 : 1UL << 28; + f->symbolize = false; + f->verbosity = 0; + f->redzone = (ASAN_LOW_MEMORY) ? 64 : 128; // power of two, >= 32. + f->debug = 0; + f->poison_shadow = true; + f->report_globals = 1; + f->malloc_context_size = kMallocContextSize; + f->replace_str = true; + f->replace_intrin = true; + f->replace_cfallocator = true; // Used on Mac only. + f->mac_ignore_invalid_free = false; // Used on Mac only. + f->use_fake_stack = true; + f->max_malloc_fill_size = 0; + f->exitcode = ASAN_DEFAULT_FAILURE_EXITCODE; + f->allow_user_poisoning = true; + f->sleep_before_dying = 0; + f->handle_segv = ASAN_NEEDS_SEGV; + f->use_sigaltstack = false; + f->check_malloc_usable_size = true; + f->unmap_shadow_on_exit = false; + f->abort_on_error = false; + f->atexit = false; + f->disable_core = (__WORDSIZE == 64); + + // Let a frontend override. + OverrideFlags(f); + + // Override from user-specified string. +#if !defined(_WIN32) + if (__asan_default_options) { + ParseFlagsFromString(f, __asan_default_options); + if (flags()->verbosity) { + Report("Using the defaults from __asan_default_options: %s\n", + __asan_default_options); + } + } +#endif + + // Override from command line. + ParseFlagsFromString(f, env); +} // -------------------------- Globals --------------------- {{{1 int asan_inited; @@ -264,44 +331,6 @@ static NOINLINE void force_interface_symbols() { } // -------------------------- Init ------------------- {{{1 -static void IntFlagValue(const char *flags, const char *flag, - s64 *out_val) { - if (!flags) return; - const char *str = internal_strstr(flags, flag); - if (!str) return; - *out_val = internal_atoll(str + internal_strlen(flag)); -} - -static void BoolFlagValue(const char *flags, const char *flag, - bool *out_val) { - if (!flags) return; - const char *str = internal_strstr(flags, flag); - if (!str) return; - const char *suffix = str + internal_strlen(flag); - if (!internal_atoll(str + internal_strlen(flag))) { - if (suffix[0] == '0') { - *out_val = false; - return; - } - } else { - *out_val = true; - return; - } - switch (suffix[0]) { - case 'y': - case 't': { - *out_val = true; - break; - } - case 'n': - case 'f': { - *out_val = false; - break; - } - default: return; - } -} - static void asan_atexit() { AsanPrintf("AddressSanitizer exit stats:\n"); __asan_print_accumulated_stats(); @@ -313,8 +342,8 @@ static void asan_atexit() { using namespace __asan; // NOLINT int __asan_set_error_exit_code(int exit_code) { - int old = FLAG_exitcode; - FLAG_exitcode = exit_code; + int old = flags()->exitcode; + flags()->exitcode = exit_code; return old; } @@ -403,7 +432,7 @@ void __asan_report_error(uptr pc, uptr bp, uptr sp, access_size ? (is_write ? "WRITE" : "READ") : "ACCESS", access_size, (void*)addr, curr_tid); - if (FLAG_debug) { + if (flags()->debug) { PrintBytes("PC: ", (uptr*)pc); } @@ -437,48 +466,6 @@ void __asan_report_error(uptr pc, uptr bp, uptr sp, Die(); } -static void ParseAsanOptions(const char *options) { - IntFlagValue(options, "malloc_context_size=", - (s64*)&FLAG_malloc_context_size); - CHECK(FLAG_malloc_context_size <= kMallocContextSize); - - IntFlagValue(options, "max_malloc_fill_size=", - (s64*)&FLAG_max_malloc_fill_size); - - IntFlagValue(options, "verbosity=", &FLAG_v); - - IntFlagValue(options, "redzone=", (s64*)&FLAG_redzone); - CHECK(FLAG_redzone >= 16); - CHECK(IsPowerOfTwo(FLAG_redzone)); - IntFlagValue(options, "quarantine_size=", (s64*)&FLAG_quarantine_size); - - IntFlagValue(options, "atexit=", &FLAG_atexit); - BoolFlagValue(options, "poison_shadow=", &FLAG_poison_shadow); - IntFlagValue(options, "report_globals=", &FLAG_report_globals); - BoolFlagValue(options, "handle_segv=", &FLAG_handle_segv); - BoolFlagValue(options, "use_sigaltstack=", &FLAG_use_sigaltstack); - BoolFlagValue(options, "symbolize=", &FLAG_symbolize); - IntFlagValue(options, "demangle=", &FLAG_demangle); - IntFlagValue(options, "debug=", &FLAG_debug); - BoolFlagValue(options, "replace_cfallocator=", &FLAG_replace_cfallocator); - BoolFlagValue(options, "mac_ignore_invalid_free=", - &FLAG_mac_ignore_invalid_free); - BoolFlagValue(options, "replace_str=", &FLAG_replace_str); - BoolFlagValue(options, "replace_intrin=", &FLAG_replace_intrin); - BoolFlagValue(options, "use_fake_stack=", &FLAG_use_fake_stack); - IntFlagValue(options, "exitcode=", &FLAG_exitcode); - BoolFlagValue(options, "allow_user_poisoning=", &FLAG_allow_user_poisoning); - IntFlagValue(options, "sleep_before_dying=", &FLAG_sleep_before_dying); - BoolFlagValue(options, "abort_on_error=", &FLAG_abort_on_error); - BoolFlagValue(options, "unmap_shadow_on_exit=", &FLAG_unmap_shadow_on_exit); - // By default, disable core dumper on 64-bit -- - // it makes little sense to dump 16T+ core. - BoolFlagValue(options, "disable_core=", &FLAG_disable_core); - - // Allow the users to work around the bug in Nvidia drivers prior to 295.*. - BoolFlagValue(options, "check_malloc_usable_size=", - &FLAG_check_malloc_usable_size); -} void __asan_init() { if (asan_inited) return; @@ -487,24 +474,15 @@ void __asan_init() { // Make sure we are not statically linked. AsanDoesNotSupportStaticLinkage(); -#if !defined(_WIN32) - if (__asan_default_options) { - ParseAsanOptions(__asan_default_options); - if (FLAG_v) { - Report("Using the defaults from __asan_default_options: %s\n", - __asan_default_options); - } - } -#endif - // flags + // Initialize flags. const char *options = GetEnv("ASAN_OPTIONS"); - ParseAsanOptions(options); + InitializeFlags(flags(), options); - if (FLAG_v && options) { + if (flags()->verbosity && options) { Report("Parsed ASAN_OPTIONS: %s\n", options); } - if (FLAG_atexit) { + if (flags()->atexit) { Atexit(asan_atexit); } @@ -514,7 +492,7 @@ void __asan_init() { ReplaceSystemMalloc(); ReplaceOperatorsNewAndDelete(); - if (FLAG_v) { + if (flags()->verbosity) { Printf("|| `[%p, %p]` || HighMem ||\n", (void*)kHighMemBeg, (void*)kHighMemEnd); Printf("|| `[%p, %p]` || HighShadow ||\n", @@ -530,8 +508,8 @@ void __asan_init() { (void*)MEM_TO_SHADOW(kLowShadowEnd), (void*)MEM_TO_SHADOW(kHighShadowBeg), (void*)MEM_TO_SHADOW(kHighShadowEnd)); - Printf("red_zone=%zu\n", (uptr)FLAG_redzone); - Printf("malloc_context_size=%zu\n", (uptr)FLAG_malloc_context_size); + Printf("red_zone=%zu\n", (uptr)flags()->redzone); + Printf("malloc_context_size=%zu\n", (uptr)flags()->malloc_context_size); Printf("SHADOW_SCALE: %zx\n", (uptr)SHADOW_SCALE); Printf("SHADOW_GRANULARITY: %zx\n", (uptr)SHADOW_GRANULARITY); @@ -539,7 +517,7 @@ void __asan_init() { CHECK(SHADOW_SCALE >= 3 && SHADOW_SCALE <= 7); } - if (FLAG_disable_core) { + if (flags()->disable_core) { DisableCoreDumper(); } @@ -574,7 +552,7 @@ void __asan_init() { asanThreadRegistry().GetMain()->ThreadStart(); force_interface_symbols(); // no-op. - if (FLAG_v) { + if (flags()->verbosity) { Report("AddressSanitizer Init done\n"); } } diff --git a/compiler-rt/lib/asan/asan_stack.cc b/compiler-rt/lib/asan/asan_stack.cc index b46c5f49cd8..f90c69b4a9c 100644 --- a/compiler-rt/lib/asan/asan_stack.cc +++ b/compiler-rt/lib/asan/asan_stack.cc @@ -45,7 +45,7 @@ void AsanStackTrace::PrintStack(uptr *addr, uptr size) { uptr pc = addr[i]; AddressInfo addr_frames[64]; uptr addr_frames_num = 0; - if (FLAG_symbolize) { + if (flags()->symbolize) { bool last_frame = (i == size - 1) || !addr[i + 1]; addr_frames_num = SymbolizeCode(pc - !last_frame, addr_frames, ASAN_ARRAY_SIZE(addr_frames)); diff --git a/compiler-rt/lib/asan/asan_stack.h b/compiler-rt/lib/asan/asan_stack.h index 35a6af2dd90..6ca9a0b28bf 100644 --- a/compiler-rt/lib/asan/asan_stack.h +++ b/compiler-rt/lib/asan/asan_stack.h @@ -90,10 +90,10 @@ struct AsanStackTrace { AsanStackTrace::GetCurrentPc(), GET_CURRENT_FRAME()) #define GET_STACK_TRACE_HERE_FOR_MALLOC \ - GET_STACK_TRACE_HERE(FLAG_malloc_context_size) + GET_STACK_TRACE_HERE(flags()->malloc_context_size) #define GET_STACK_TRACE_HERE_FOR_FREE(ptr) \ - GET_STACK_TRACE_HERE(FLAG_malloc_context_size) + GET_STACK_TRACE_HERE(flags()->malloc_context_size) #define PRINT_CURRENT_STACK() \ { \ diff --git a/compiler-rt/lib/asan/asan_thread.cc b/compiler-rt/lib/asan/asan_thread.cc index e2fa416f069..2f2773212f7 100644 --- a/compiler-rt/lib/asan/asan_thread.cc +++ b/compiler-rt/lib/asan/asan_thread.cc @@ -42,7 +42,7 @@ AsanThread *AsanThread::Create(u32 parent_tid, thread_callback_t start_routine, void AsanThreadSummary::TSDDtor(void *tsd) { AsanThreadSummary *summary = (AsanThreadSummary*)tsd; - if (FLAG_v >= 1) { + if (flags()->verbosity >= 1) { Report("T%d TSDDtor\n", summary->tid()); } if (summary->thread()) { @@ -51,7 +51,7 @@ void AsanThreadSummary::TSDDtor(void *tsd) { } void AsanThread::Destroy() { - if (FLAG_v >= 1) { + if (flags()->verbosity >= 1) { Report("T%d exited\n", tid()); } @@ -71,7 +71,7 @@ void AsanThread::Init() { CHECK(AddrIsInMem(stack_bottom_)); CHECK(AddrIsInMem(stack_top_)); ClearShadowForThreadStack(); - if (FLAG_v >= 1) { + if (flags()->verbosity >= 1) { int local = 0; Report("T%d: stack [%p,%p) size 0x%zx; local=%p\n", tid(), (void*)stack_bottom_, (void*)stack_top_, @@ -82,7 +82,7 @@ void AsanThread::Init() { thread_return_t AsanThread::ThreadStart() { Init(); - if (FLAG_use_sigaltstack) SetAlternateSignalStack(); + if (flags()->use_sigaltstack) SetAlternateSignalStack(); if (!start_routine_) { // start_routine_ == 0 if we're on the main thread or on one of the @@ -94,7 +94,7 @@ thread_return_t AsanThread::ThreadStart() { thread_return_t res = start_routine_(arg_); malloc_storage().CommitBack(); - if (FLAG_use_sigaltstack) UnsetAlternateSignalStack(); + if (flags()->use_sigaltstack) UnsetAlternateSignalStack(); this->Destroy(); diff --git a/compiler-rt/lib/asan/asan_thread_registry.cc b/compiler-rt/lib/asan/asan_thread_registry.cc index 444900d42ec..4540d589c55 100644 --- a/compiler-rt/lib/asan/asan_thread_registry.cc +++ b/compiler-rt/lib/asan/asan_thread_registry.cc @@ -88,7 +88,7 @@ AsanThread *AsanThreadRegistry::GetCurrent() { void AsanThreadRegistry::SetCurrent(AsanThread *t) { CHECK(t->summary()); - if (FLAG_v >= 2) { + if (flags()->verbosity >= 2) { Report("SetCurrent: %p for thread %p\n", t->summary(), (void*)GetThreadSelf()); } |