Index: lib/lsan/lsan_thread.cc =================================================================== --- lib/lsan/lsan_thread.cc +++ lib/lsan/lsan_thread.cc @@ -120,8 +120,10 @@ } void EnsureMainThreadIDIsCorrect() { - if (GetCurrentThread() == 0) - CurrentThreadContext()->os_id = GetTid(); + if (GetCurrentThread() == 0) { + ThreadContext *tc = CurrentThreadContext(); + if (tc) tc->os_id = GetTid(); + } } ///// Interface to the common LSan module. ///// Index: lib/sanitizer_common/sanitizer_libc.cc =================================================================== --- lib/sanitizer_common/sanitizer_libc.cc +++ lib/sanitizer_common/sanitizer_libc.cc @@ -114,8 +114,8 @@ int internal_strcmp(const char *s1, const char *s2) { while (true) { - unsigned c1 = *s1; - unsigned c2 = *s2; + char c1 = *s1; + char c2 = *s2; if (c1 != c2) return (c1 < c2) ? -1 : 1; if (c1 == 0) break; s1++; @@ -126,8 +126,8 @@ int internal_strncmp(const char *s1, const char *s2, uptr n) { for (uptr i = 0; i < n; i++) { - unsigned c1 = *s1; - unsigned c2 = *s2; + char c1 = *s1; + char c2 = *s2; if (c1 != c2) return (c1 < c2) ? -1 : 1; if (c1 == 0) break; s1++; Index: lib/sanitizer_common/sanitizer_libignore.cc =================================================================== --- lib/sanitizer_common/sanitizer_libignore.cc +++ lib/sanitizer_common/sanitizer_libignore.cc @@ -18,7 +18,15 @@ namespace __sanitizer { -LibIgnore::LibIgnore(LinkerInitialized) { +LibIgnore::LibIgnore(LinkerInitialized) + : mutex_(), count_(0), + track_instrumented_libs_(false) { + atomic_store_relaxed(&ignored_ranges_count_, 0); + atomic_store_relaxed(&instrumented_ranges_count_, 0); + internal_memset(ignored_code_ranges_, 0, sizeof(ignored_code_ranges_)); + internal_memset(instrumented_code_ranges_, 0, + sizeof(instrumented_code_ranges_)); + internal_memset(libs_, 0, sizeof(libs_)); } void LibIgnore::AddIgnoredLibrary(const char *name_templ) { Index: lib/sanitizer_common/sanitizer_printf.cc =================================================================== --- lib/sanitizer_common/sanitizer_printf.cc +++ lib/sanitizer_common/sanitizer_printf.cc @@ -61,7 +61,8 @@ if (pos < minimal_num_length) { // Make sure compiler doesn't insert call to memset here. internal_memset(&num_buffer[pos], 0, - sizeof(num_buffer[0]) * (minimal_num_length - pos)); + sizeof(num_buffer[0]) * + ((u64)minimal_num_length - (u64)pos)); pos = minimal_num_length; } RAW_CHECK(pos > 0); Index: lib/sanitizer_common/sanitizer_symbolizer_posix_libcdep.cc =================================================================== --- lib/sanitizer_common/sanitizer_symbolizer_posix_libcdep.cc +++ lib/sanitizer_common/sanitizer_symbolizer_posix_libcdep.cc @@ -448,28 +448,31 @@ static SymbolizerTool *ChooseExternalSymbolizer(LowLevelAllocator *allocator) { const char *path = common_flags()->external_symbolizer_path; const char *binary_name = path ? StripModuleName(path) : ""; - if (path && path[0] == '\0') { - VReport(2, "External symbolizer is explicitly disabled.\n"); - return nullptr; - } else if (!internal_strcmp(binary_name, "llvm-symbolizer")) { - VReport(2, "Using llvm-symbolizer at user-specified path: %s\n", path); - return new(*allocator) LLVMSymbolizer(path, allocator); - } else if (!internal_strcmp(binary_name, "atos")) { + + if (path) { + if (path[0] == '\0') { + VReport(2, "External symbolizer is explicitly disabled.\n"); + return nullptr; + } else if (!internal_strcmp(binary_name, "llvm-symbolizer")) { + VReport(2, "Using llvm-symbolizer at user-specified path: %s\n", path); + return new(*allocator) LLVMSymbolizer(path, allocator); + } else if (!internal_strcmp(binary_name, "atos")) { #if SANITIZER_MAC - VReport(2, "Using atos at user-specified path: %s\n", path); - return new(*allocator) AtosSymbolizer(path, allocator); + VReport(2, "Using atos at user-specified path: %s\n", path); + return new(*allocator) AtosSymbolizer(path, allocator); #else // SANITIZER_MAC - Report("ERROR: Using `atos` is only supported on Darwin.\n"); - Die(); + Report("ERROR: Using `atos` is only supported on Darwin.\n"); + Die(); #endif // SANITIZER_MAC - } else if (!internal_strcmp(binary_name, "addr2line")) { - VReport(2, "Using addr2line at user-specified path: %s\n", path); - return new(*allocator) Addr2LinePool(path, allocator); - } else if (path) { - Report("ERROR: External symbolizer path is set to '%s' which isn't " - "a known symbolizer. Please set the path to the llvm-symbolizer " - "binary or other known tool.\n", path); - Die(); + } else if (!internal_strcmp(binary_name, "addr2line")) { + VReport(2, "Using addr2line at user-specified path: %s\n", path); + return new(*allocator) Addr2LinePool(path, allocator); + } else { + Report("ERROR: External symbolizer path is set to '%s' which isn't " + "a known symbolizer. Please set the path to the llvm-symbolizer " + "binary or other known tool.\n", path); + Die(); + } } // Otherwise symbolizer program is unknown, let's search $PATH