Skip site navigation (1)Skip section navigation (2)
Date:      Sat, 10 Jun 2017 13:44:32 +0000 (UTC)
From:      Dimitry Andric <dim@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-vendor@freebsd.org
Subject:   svn commit: r319784 - in vendor/compiler-rt/dist: . lib/asan lib/lsan lib/msan lib/sanitizer_common lib/sanitizer_common/symbolizer/scripts lib/tsan/rtl test/asan/TestCases/Darwin test/asan/TestCas...
Message-ID:  <201706101344.v5ADiWx2094820@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: dim
Date: Sat Jun 10 13:44:32 2017
New Revision: 319784
URL: https://svnweb.freebsd.org/changeset/base/319784

Log:
  Vendor import of compiler-rt trunk r305145:
  https://llvm.org/svn/llvm-project/compiler-rt/trunk@305145

Added:
  vendor/compiler-rt/dist/test/asan/TestCases/Linux/asan_preload_test-3.cc   (contents, props changed)
  vendor/compiler-rt/dist/test/msan/Linux/strerror_r.cc   (contents, props changed)
  vendor/compiler-rt/dist/test/tsan/strerror_r.cc   (contents, props changed)
Deleted:
  vendor/compiler-rt/dist/test/sanitizer_common/TestCases/Linux/allocator_fork_no_hang.cc
Modified:
  vendor/compiler-rt/dist/CMakeLists.txt
  vendor/compiler-rt/dist/lib/asan/asan_allocator.cc
  vendor/compiler-rt/dist/lib/asan/asan_allocator.h
  vendor/compiler-rt/dist/lib/asan/asan_interceptors.cc
  vendor/compiler-rt/dist/lib/asan/asan_malloc_linux.cc
  vendor/compiler-rt/dist/lib/lsan/lsan_common.cc
  vendor/compiler-rt/dist/lib/lsan/lsan_common_linux.cc
  vendor/compiler-rt/dist/lib/lsan/lsan_interceptors.cc
  vendor/compiler-rt/dist/lib/msan/msan_allocator.cc
  vendor/compiler-rt/dist/lib/msan/msan_allocator.h
  vendor/compiler-rt/dist/lib/msan/msan_interceptors.cc
  vendor/compiler-rt/dist/lib/sanitizer_common/sanitizer_common_interceptors.inc
  vendor/compiler-rt/dist/lib/sanitizer_common/sanitizer_linux.cc
  vendor/compiler-rt/dist/lib/sanitizer_common/sanitizer_platform.h
  vendor/compiler-rt/dist/lib/sanitizer_common/symbolizer/scripts/build_symbolizer.sh
  vendor/compiler-rt/dist/lib/tsan/rtl/tsan_rtl_thread.cc
  vendor/compiler-rt/dist/test/asan/TestCases/Darwin/atos-symbolizer.cc
  vendor/compiler-rt/dist/test/asan/TestCases/Posix/halt_on_error-torture.cc
  vendor/compiler-rt/dist/test/profile/Linux/instrprof-alloc.test
  vendor/compiler-rt/dist/test/profile/Linux/instrprof-value-prof-warn.test
  vendor/compiler-rt/dist/test/sanitizer_common/TestCases/sanitizer_coverage_inline8bit_counter.cc

Modified: vendor/compiler-rt/dist/CMakeLists.txt
==============================================================================
--- vendor/compiler-rt/dist/CMakeLists.txt	Sat Jun 10 13:44:29 2017	(r319783)
+++ vendor/compiler-rt/dist/CMakeLists.txt	Sat Jun 10 13:44:32 2017	(r319784)
@@ -255,7 +255,7 @@ if(EXISTS ${COMPILER_RT_LLD_PATH}/ AND LLVM_TOOL_LLD_B
   set(COMPILER_RT_HAS_LLD TRUE)
 else()
   set(COMPILER_RT_LLD_PATH ${LLVM_MAIN_SRC_DIR}/../lld)
-  if(EXISTS ${COMPILER_RT_LLD_PATH}/)
+  if(EXISTS ${COMPILER_RT_LLD_PATH}/ AND LLVM_TOOL_LLD_BUILD)
     set(COMPILER_RT_HAS_LLD TRUE)
   else()
     set(COMPILER_RT_HAS_LLD FALSE)

Modified: vendor/compiler-rt/dist/lib/asan/asan_allocator.cc
==============================================================================
--- vendor/compiler-rt/dist/lib/asan/asan_allocator.cc	Sat Jun 10 13:44:29 2017	(r319783)
+++ vendor/compiler-rt/dist/lib/asan/asan_allocator.cc	Sat Jun 10 13:44:32 2017	(r319784)
@@ -47,6 +47,8 @@ static u32 RZSize2Log(u32 rz_size) {
   return res;
 }
 
+static AsanAllocator &get_allocator();
+
 // The memory chunk allocated from the underlying allocator looks like this:
 // L L L L L L H H U U U U U U R R
 //   L -- left redzone words (0 or more bytes)
@@ -717,7 +719,7 @@ struct Allocator {
 
 static Allocator instance(LINKER_INITIALIZED);
 
-AsanAllocator &get_allocator() {
+static AsanAllocator &get_allocator() {
   return instance.allocator;
 }
 

Modified: vendor/compiler-rt/dist/lib/asan/asan_allocator.h
==============================================================================
--- vendor/compiler-rt/dist/lib/asan/asan_allocator.h	Sat Jun 10 13:44:29 2017	(r319783)
+++ vendor/compiler-rt/dist/lib/asan/asan_allocator.h	Sat Jun 10 13:44:32 2017	(r319784)
@@ -213,7 +213,5 @@ void asan_mz_force_unlock();
 void PrintInternalAllocatorStats();
 void AsanSoftRssLimitExceededCallback(bool exceeded);
 
-AsanAllocator &get_allocator();
-
 }  // namespace __asan
 #endif  // ASAN_ALLOCATOR_H

Modified: vendor/compiler-rt/dist/lib/asan/asan_interceptors.cc
==============================================================================
--- vendor/compiler-rt/dist/lib/asan/asan_interceptors.cc	Sat Jun 10 13:44:29 2017	(r319783)
+++ vendor/compiler-rt/dist/lib/asan/asan_interceptors.cc	Sat Jun 10 13:44:32 2017	(r319784)
@@ -22,7 +22,6 @@
 #include "asan_stats.h"
 #include "asan_suppressions.h"
 #include "lsan/lsan_common.h"
-#include "sanitizer_common/sanitizer_stackdepot.h"
 #include "sanitizer_common/sanitizer_libc.h"
 
 #if SANITIZER_POSIX
@@ -705,25 +704,9 @@ INTERCEPTOR(int, __cxa_atexit, void (*func)(void *), v
 #endif  // ASAN_INTERCEPT___CXA_ATEXIT
 
 #if ASAN_INTERCEPT_FORK
-static void BeforeFork() {
-  if (SANITIZER_LINUX) {
-    get_allocator().ForceLock();
-    StackDepotLockAll();
-  }
-}
-
-static void AfterFork() {
-  if (SANITIZER_LINUX) {
-    StackDepotUnlockAll();
-    get_allocator().ForceUnlock();
-  }
-}
-
 INTERCEPTOR(int, fork, void) {
   ENSURE_ASAN_INITED();
-  BeforeFork();
   int pid = REAL(fork)();
-  AfterFork();
   return pid;
 }
 #endif  // ASAN_INTERCEPT_FORK

Modified: vendor/compiler-rt/dist/lib/asan/asan_malloc_linux.cc
==============================================================================
--- vendor/compiler-rt/dist/lib/asan/asan_malloc_linux.cc	Sat Jun 10 13:44:29 2017	(r319783)
+++ vendor/compiler-rt/dist/lib/asan/asan_malloc_linux.cc	Sat Jun 10 13:44:32 2017	(r319784)
@@ -60,36 +60,42 @@ INTERCEPTOR(void, cfree, void *ptr) {
 #endif // SANITIZER_INTERCEPT_CFREE
 
 INTERCEPTOR(void*, malloc, uptr size) {
-  if (UNLIKELY(!asan_inited))
+  if (UNLIKELY(asan_init_is_running))
     // Hack: dlsym calls malloc before REAL(malloc) is retrieved from dlsym.
     return AllocateFromLocalPool(size);
+  ENSURE_ASAN_INITED();
   GET_STACK_TRACE_MALLOC;
   return asan_malloc(size, &stack);
 }
 
 INTERCEPTOR(void*, calloc, uptr nmemb, uptr size) {
-  if (UNLIKELY(!asan_inited))
+  if (UNLIKELY(asan_init_is_running))
     // Hack: dlsym calls calloc before REAL(calloc) is retrieved from dlsym.
     return AllocateFromLocalPool(nmemb * size);
+  ENSURE_ASAN_INITED();
   GET_STACK_TRACE_MALLOC;
   return asan_calloc(nmemb, size, &stack);
 }
 
 INTERCEPTOR(void*, realloc, void *ptr, uptr size) {
-  GET_STACK_TRACE_MALLOC;
   if (UNLIKELY(IsInDlsymAllocPool(ptr))) {
-    uptr offset = (uptr)ptr - (uptr)alloc_memory_for_dlsym;
-    uptr copy_size = Min(size, kDlsymAllocPoolSize - offset);
+    const uptr offset = (uptr)ptr - (uptr)alloc_memory_for_dlsym;
+    const uptr copy_size = Min(size, kDlsymAllocPoolSize - offset);
     void *new_ptr;
-    if (UNLIKELY(!asan_inited)) {
+    if (UNLIKELY(asan_init_is_running)) {
       new_ptr = AllocateFromLocalPool(size);
     } else {
-      copy_size = size;
-      new_ptr = asan_malloc(copy_size, &stack);
+      ENSURE_ASAN_INITED();
+      GET_STACK_TRACE_MALLOC;
+      new_ptr = asan_malloc(size, &stack);
     }
     internal_memcpy(new_ptr, ptr, copy_size);
     return new_ptr;
   }
+  if (UNLIKELY(asan_init_is_running))
+    return AllocateFromLocalPool(size);
+  ENSURE_ASAN_INITED();
+  GET_STACK_TRACE_MALLOC;
   return asan_realloc(ptr, size, &stack);
 }
 

Modified: vendor/compiler-rt/dist/lib/lsan/lsan_common.cc
==============================================================================
--- vendor/compiler-rt/dist/lib/lsan/lsan_common.cc	Sat Jun 10 13:44:29 2017	(r319783)
+++ vendor/compiler-rt/dist/lib/lsan/lsan_common.cc	Sat Jun 10 13:44:32 2017	(r319784)
@@ -408,9 +408,6 @@ static void MarkInvalidPCCb(uptr chunk, void *arg) {
 
 // On Linux, handles dynamically allocated TLS blocks by treating all chunks
 // allocated from ld-linux.so as reachable.
-// On Linux, treats all chunks allocated from ld-linux.so as reachable, which
-// covers dynamically allocated TLS blocks, internal dynamic loader's loaded
-// modules accounting etc.
 // Dynamic TLS blocks contain the TLS variables of dynamically loaded modules.
 // They are allocated with a __libc_memalign() call in allocate_and_init()
 // (elf/dl-tls.c). Glibc won't tell us the address ranges occupied by those

Modified: vendor/compiler-rt/dist/lib/lsan/lsan_common_linux.cc
==============================================================================
--- vendor/compiler-rt/dist/lib/lsan/lsan_common_linux.cc	Sat Jun 10 13:44:29 2017	(r319783)
+++ vendor/compiler-rt/dist/lib/lsan/lsan_common_linux.cc	Sat Jun 10 13:44:32 2017	(r319784)
@@ -23,10 +23,6 @@
 #include "sanitizer_common/sanitizer_linux.h"
 #include "sanitizer_common/sanitizer_stackdepot.h"
 
-#if SANITIZER_USE_GETAUXVAL
-#include <sys/auxv.h>
-#endif  // SANITIZER_USE_GETAUXVAL
-
 namespace __lsan {
 
 static const char kLinkerName[] = "ld";
@@ -34,12 +30,8 @@ static const char kLinkerName[] = "ld";
 static char linker_placeholder[sizeof(LoadedModule)] ALIGNED(64);
 static LoadedModule *linker = nullptr;
 
-static bool IsLinker(const LoadedModule& module) {
-#if SANITIZER_USE_GETAUXVAL
-  return module.base_address() == getauxval(AT_BASE);
-#else
-  return LibraryNameIs(module.full_name(), kLinkerName);
-#endif  // SANITIZER_USE_GETAUXVAL
+static bool IsLinker(const char* full_name) {
+  return LibraryNameIs(full_name, kLinkerName);
 }
 
 __attribute__((tls_model("initial-exec")))
@@ -57,25 +49,22 @@ void InitializePlatformSpecificModules() {
   ListOfModules modules;
   modules.init();
   for (LoadedModule &module : modules) {
-    if (!IsLinker(module))
-      continue;
+    if (!IsLinker(module.full_name())) continue;
     if (linker == nullptr) {
       linker = reinterpret_cast<LoadedModule *>(linker_placeholder);
       *linker = module;
       module = LoadedModule();
     } else {
       VReport(1, "LeakSanitizer: Multiple modules match \"%s\". "
-                 "TLS and other allocations originating from linker might be "
-                 "falsely reported as leaks.\n", kLinkerName);
+              "TLS will not be handled correctly.\n", kLinkerName);
       linker->clear();
       linker = nullptr;
       return;
     }
   }
   if (linker == nullptr) {
-    VReport(1, "LeakSanitizer: Dynamic linker not found. TLS and other "
-               "allocations originating from linker might be falsely reported "
-                "as leaks.\n");
+    VReport(1, "LeakSanitizer: Dynamic linker not found. "
+               "TLS will not be handled correctly.\n");
   }
 }
 

Modified: vendor/compiler-rt/dist/lib/lsan/lsan_interceptors.cc
==============================================================================
--- vendor/compiler-rt/dist/lib/lsan/lsan_interceptors.cc	Sat Jun 10 13:44:29 2017	(r319783)
+++ vendor/compiler-rt/dist/lib/lsan/lsan_interceptors.cc	Sat Jun 10 13:44:32 2017	(r319784)
@@ -22,7 +22,6 @@
 #include "sanitizer_common/sanitizer_platform_interceptors.h"
 #include "sanitizer_common/sanitizer_platform_limits_posix.h"
 #include "sanitizer_common/sanitizer_posix.h"
-#include "sanitizer_common/sanitizer_stackdepot.h"
 #include "sanitizer_common/sanitizer_tls_get_addr.h"
 #include "lsan.h"
 #include "lsan_allocator.h"
@@ -98,28 +97,6 @@ INTERCEPTOR(void*, valloc, uptr size) {
 }
 #endif
 
-static void BeforeFork() {
-  if (SANITIZER_LINUX) {
-    LockAllocator();
-    StackDepotLockAll();
-  }
-}
-
-static void AfterFork() {
-  if (SANITIZER_LINUX) {
-    StackDepotUnlockAll();
-    UnlockAllocator();
-  }
-}
-
-INTERCEPTOR(int, fork, void) {
-  ENSURE_LSAN_INITED;
-  BeforeFork();
-  int pid = REAL(fork)();
-  AfterFork();
-  return pid;
-}
-
 #if SANITIZER_INTERCEPT_MEMALIGN
 INTERCEPTOR(void*, memalign, uptr alignment, uptr size) {
   ENSURE_LSAN_INITED;
@@ -359,7 +336,6 @@ void InitializeInterceptors() {
   LSAN_MAYBE_INTERCEPT_MALLOPT;
   INTERCEPT_FUNCTION(pthread_create);
   INTERCEPT_FUNCTION(pthread_join);
-  INTERCEPT_FUNCTION(fork);
 
   if (pthread_key_create(&g_thread_finalize_key, &thread_finalize)) {
     Report("LeakSanitizer: failed to create thread key.\n");

Modified: vendor/compiler-rt/dist/lib/msan/msan_allocator.cc
==============================================================================
--- vendor/compiler-rt/dist/lib/msan/msan_allocator.cc	Sat Jun 10 13:44:29 2017	(r319783)
+++ vendor/compiler-rt/dist/lib/msan/msan_allocator.cc	Sat Jun 10 13:44:32 2017	(r319784)
@@ -12,6 +12,8 @@
 // MemorySanitizer allocator.
 //===----------------------------------------------------------------------===//
 
+#include "sanitizer_common/sanitizer_allocator.h"
+#include "sanitizer_common/sanitizer_allocator_interface.h"
 #include "msan.h"
 #include "msan_allocator.h"
 #include "msan_origin.h"
@@ -20,11 +22,101 @@
 
 namespace __msan {
 
+struct Metadata {
+  uptr requested_size;
+};
+
+struct MsanMapUnmapCallback {
+  void OnMap(uptr p, uptr size) const {}
+  void OnUnmap(uptr p, uptr size) const {
+    __msan_unpoison((void *)p, size);
+
+    // We are about to unmap a chunk of user memory.
+    // Mark the corresponding shadow memory as not needed.
+    uptr shadow_p = MEM_TO_SHADOW(p);
+    ReleaseMemoryPagesToOS(shadow_p, shadow_p + size);
+    if (__msan_get_track_origins()) {
+      uptr origin_p = MEM_TO_ORIGIN(p);
+      ReleaseMemoryPagesToOS(origin_p, origin_p + size);
+    }
+  }
+};
+
+#if defined(__mips64)
+  static const uptr kMaxAllowedMallocSize = 2UL << 30;
+  static const uptr kRegionSizeLog = 20;
+  static const uptr kNumRegions = SANITIZER_MMAP_RANGE_SIZE >> kRegionSizeLog;
+  typedef TwoLevelByteMap<(kNumRegions >> 12), 1 << 12> ByteMap;
+
+  struct AP32 {
+    static const uptr kSpaceBeg = 0;
+    static const u64 kSpaceSize = SANITIZER_MMAP_RANGE_SIZE;
+    static const uptr kMetadataSize = sizeof(Metadata);
+    typedef __sanitizer::CompactSizeClassMap SizeClassMap;
+    static const uptr kRegionSizeLog = __msan::kRegionSizeLog;
+    typedef __msan::ByteMap ByteMap;
+    typedef MsanMapUnmapCallback MapUnmapCallback;
+    static const uptr kFlags = 0;
+  };
+  typedef SizeClassAllocator32<AP32> PrimaryAllocator;
+#elif defined(__x86_64__)
+#if SANITIZER_LINUX && !defined(MSAN_LINUX_X86_64_OLD_MAPPING)
+  static const uptr kAllocatorSpace = 0x700000000000ULL;
+#else
+  static const uptr kAllocatorSpace = 0x600000000000ULL;
+#endif
+  static const uptr kMaxAllowedMallocSize = 8UL << 30;
+
+  struct AP64 {  // Allocator64 parameters. Deliberately using a short name.
+    static const uptr kSpaceBeg = kAllocatorSpace;
+    static const uptr kSpaceSize = 0x40000000000; // 4T.
+    static const uptr kMetadataSize = sizeof(Metadata);
+    typedef DefaultSizeClassMap SizeClassMap;
+    typedef MsanMapUnmapCallback MapUnmapCallback;
+    static const uptr kFlags = 0;
+  };
+
+  typedef SizeClassAllocator64<AP64> PrimaryAllocator;
+
+#elif defined(__powerpc64__)
+  static const uptr kMaxAllowedMallocSize = 2UL << 30;  // 2G
+
+  struct AP64 {  // Allocator64 parameters. Deliberately using a short name.
+    static const uptr kSpaceBeg = 0x300000000000;
+    static const uptr kSpaceSize = 0x020000000000; // 2T.
+    static const uptr kMetadataSize = sizeof(Metadata);
+    typedef DefaultSizeClassMap SizeClassMap;
+    typedef MsanMapUnmapCallback MapUnmapCallback;
+    static const uptr kFlags = 0;
+  };
+
+  typedef SizeClassAllocator64<AP64> PrimaryAllocator;
+#elif defined(__aarch64__)
+  static const uptr kMaxAllowedMallocSize = 2UL << 30;  // 2G
+  static const uptr kRegionSizeLog = 20;
+  static const uptr kNumRegions = SANITIZER_MMAP_RANGE_SIZE >> kRegionSizeLog;
+  typedef TwoLevelByteMap<(kNumRegions >> 12), 1 << 12> ByteMap;
+
+  struct AP32 {
+    static const uptr kSpaceBeg = 0;
+    static const u64 kSpaceSize = SANITIZER_MMAP_RANGE_SIZE;
+    static const uptr kMetadataSize = sizeof(Metadata);
+    typedef __sanitizer::CompactSizeClassMap SizeClassMap;
+    static const uptr kRegionSizeLog = __msan::kRegionSizeLog;
+    typedef __msan::ByteMap ByteMap;
+    typedef MsanMapUnmapCallback MapUnmapCallback;
+    static const uptr kFlags = 0;
+  };
+  typedef SizeClassAllocator32<AP32> PrimaryAllocator;
+#endif
+typedef SizeClassAllocatorLocalCache<PrimaryAllocator> AllocatorCache;
+typedef LargeMmapAllocator<MsanMapUnmapCallback> SecondaryAllocator;
+typedef CombinedAllocator<PrimaryAllocator, AllocatorCache,
+                          SecondaryAllocator> Allocator;
+
 static Allocator allocator;
 static AllocatorCache fallback_allocator_cache;
 static SpinMutex fallback_mutex;
-
-Allocator &get_allocator() { return allocator; }
 
 void MsanAllocatorInit() {
   allocator.Init(

Modified: vendor/compiler-rt/dist/lib/msan/msan_allocator.h
==============================================================================
--- vendor/compiler-rt/dist/lib/msan/msan_allocator.h	Sat Jun 10 13:44:29 2017	(r319783)
+++ vendor/compiler-rt/dist/lib/msan/msan_allocator.h	Sat Jun 10 13:44:32 2017	(r319784)
@@ -15,105 +15,8 @@
 #define MSAN_ALLOCATOR_H
 
 #include "sanitizer_common/sanitizer_common.h"
-#include "sanitizer_common/sanitizer_allocator.h"
-#include "sanitizer_common/sanitizer_allocator_interface.h"
 
 namespace __msan {
-
-struct Metadata {
-  uptr requested_size;
-};
-
-struct MsanMapUnmapCallback {
-  void OnMap(uptr p, uptr size) const {}
-  void OnUnmap(uptr p, uptr size) const {
-    __msan_unpoison((void *)p, size);
-
-    // We are about to unmap a chunk of user memory.
-    // Mark the corresponding shadow memory as not needed.
-    uptr shadow_p = MEM_TO_SHADOW(p);
-    ReleaseMemoryPagesToOS(shadow_p, shadow_p + size);
-    if (__msan_get_track_origins()) {
-      uptr origin_p = MEM_TO_ORIGIN(p);
-      ReleaseMemoryPagesToOS(origin_p, origin_p + size);
-    }
-  }
-};
-
-#if defined(__mips64)
-  static const uptr kMaxAllowedMallocSize = 2UL << 30;
-  static const uptr kRegionSizeLog = 20;
-  static const uptr kNumRegions = SANITIZER_MMAP_RANGE_SIZE >> kRegionSizeLog;
-  typedef TwoLevelByteMap<(kNumRegions >> 12), 1 << 12> ByteMap;
-
-  struct AP32 {
-    static const uptr kSpaceBeg = 0;
-    static const u64 kSpaceSize = SANITIZER_MMAP_RANGE_SIZE;
-    static const uptr kMetadataSize = sizeof(Metadata);
-    typedef __sanitizer::CompactSizeClassMap SizeClassMap;
-    static const uptr kRegionSizeLog = __msan::kRegionSizeLog;
-    typedef __msan::ByteMap ByteMap;
-    typedef MsanMapUnmapCallback MapUnmapCallback;
-    static const uptr kFlags = 0;
-  };
-  typedef SizeClassAllocator32<AP32> PrimaryAllocator;
-#elif defined(__x86_64__)
-#if SANITIZER_LINUX && !defined(MSAN_LINUX_X86_64_OLD_MAPPING)
-  static const uptr kAllocatorSpace = 0x700000000000ULL;
-#else
-  static const uptr kAllocatorSpace = 0x600000000000ULL;
-#endif
-  static const uptr kMaxAllowedMallocSize = 8UL << 30;
-
-  struct AP64 {  // Allocator64 parameters. Deliberately using a short name.
-    static const uptr kSpaceBeg = kAllocatorSpace;
-    static const uptr kSpaceSize = 0x40000000000; // 4T.
-    static const uptr kMetadataSize = sizeof(Metadata);
-    typedef DefaultSizeClassMap SizeClassMap;
-    typedef MsanMapUnmapCallback MapUnmapCallback;
-    static const uptr kFlags = 0;
-  };
-
-  typedef SizeClassAllocator64<AP64> PrimaryAllocator;
-
-#elif defined(__powerpc64__)
-  static const uptr kMaxAllowedMallocSize = 2UL << 30;  // 2G
-
-  struct AP64 {  // Allocator64 parameters. Deliberately using a short name.
-    static const uptr kSpaceBeg = 0x300000000000;
-    static const uptr kSpaceSize = 0x020000000000; // 2T.
-    static const uptr kMetadataSize = sizeof(Metadata);
-    typedef DefaultSizeClassMap SizeClassMap;
-    typedef MsanMapUnmapCallback MapUnmapCallback;
-    static const uptr kFlags = 0;
-  };
-
-  typedef SizeClassAllocator64<AP64> PrimaryAllocator;
-#elif defined(__aarch64__)
-  static const uptr kMaxAllowedMallocSize = 2UL << 30;  // 2G
-  static const uptr kRegionSizeLog = 20;
-  static const uptr kNumRegions = SANITIZER_MMAP_RANGE_SIZE >> kRegionSizeLog;
-  typedef TwoLevelByteMap<(kNumRegions >> 12), 1 << 12> ByteMap;
-
-  struct AP32 {
-    static const uptr kSpaceBeg = 0;
-    static const u64 kSpaceSize = SANITIZER_MMAP_RANGE_SIZE;
-    static const uptr kMetadataSize = sizeof(Metadata);
-    typedef __sanitizer::CompactSizeClassMap SizeClassMap;
-    static const uptr kRegionSizeLog = __msan::kRegionSizeLog;
-    typedef __msan::ByteMap ByteMap;
-    typedef MsanMapUnmapCallback MapUnmapCallback;
-    static const uptr kFlags = 0;
-  };
-  typedef SizeClassAllocator32<AP32> PrimaryAllocator;
-#endif
-typedef SizeClassAllocatorLocalCache<PrimaryAllocator> AllocatorCache;
-typedef LargeMmapAllocator<MsanMapUnmapCallback> SecondaryAllocator;
-typedef CombinedAllocator<PrimaryAllocator, AllocatorCache,
-                          SecondaryAllocator> Allocator;
-
-
-Allocator &get_allocator();
 
 struct MsanThreadLocalMallocStorage {
   uptr quarantine_cache[16];

Modified: vendor/compiler-rt/dist/lib/msan/msan_interceptors.cc
==============================================================================
--- vendor/compiler-rt/dist/lib/msan/msan_interceptors.cc	Sat Jun 10 13:44:29 2017	(r319783)
+++ vendor/compiler-rt/dist/lib/msan/msan_interceptors.cc	Sat Jun 10 13:44:32 2017	(r319784)
@@ -1201,7 +1201,6 @@ INTERCEPTOR(void *, shmat, int shmid, const void *shma
 }
 
 static void BeforeFork() {
-  get_allocator().ForceLock();
   StackDepotLockAll();
   ChainedOriginDepotLockAll();
 }
@@ -1209,7 +1208,6 @@ static void BeforeFork() {
 static void AfterFork() {
   ChainedOriginDepotUnlockAll();
   StackDepotUnlockAll();
-  get_allocator().ForceUnlock();
 }
 
 INTERCEPTOR(int, fork, void) {

Modified: vendor/compiler-rt/dist/lib/sanitizer_common/sanitizer_common_interceptors.inc
==============================================================================
--- vendor/compiler-rt/dist/lib/sanitizer_common/sanitizer_common_interceptors.inc	Sat Jun 10 13:44:29 2017	(r319783)
+++ vendor/compiler-rt/dist/lib/sanitizer_common/sanitizer_common_interceptors.inc	Sat Jun 10 13:44:32 2017	(r319784)
@@ -3395,7 +3395,10 @@ INTERCEPTOR(char *, strerror_r, int errnum, char *buf,
   // its metadata. See
   // https://github.com/google/sanitizers/issues/321.
   char *res = REAL(strerror_r)(errnum, buf, buflen);
-  COMMON_INTERCEPTOR_WRITE_RANGE(ctx, res, REAL(strlen)(res) + 1);
+  if (res == buf)
+    COMMON_INTERCEPTOR_WRITE_RANGE(ctx, res, REAL(strlen)(res) + 1);
+  else
+    COMMON_INTERCEPTOR_INITIALIZE_RANGE(res, REAL(strlen)(res) + 1);
   return res;
 }
 #endif //(_POSIX_C_SOURCE >= 200112L || _XOPEN_SOURCE >= 600) && !_GNU_SOURCE ||

Modified: vendor/compiler-rt/dist/lib/sanitizer_common/sanitizer_linux.cc
==============================================================================
--- vendor/compiler-rt/dist/lib/sanitizer_common/sanitizer_linux.cc	Sat Jun 10 13:44:29 2017	(r319783)
+++ vendor/compiler-rt/dist/lib/sanitizer_common/sanitizer_linux.cc	Sat Jun 10 13:44:32 2017	(r319784)
@@ -75,6 +75,16 @@ extern char **environ;  // provided by crt1
 #include <sys/signal.h>
 #endif
 
+#ifndef __GLIBC_PREREQ
+#define __GLIBC_PREREQ(x, y) 0
+#endif
+
+#if SANITIZER_LINUX && __GLIBC_PREREQ(2, 16)
+# define SANITIZER_USE_GETAUXVAL 1
+#else
+# define SANITIZER_USE_GETAUXVAL 0
+#endif
+
 #if SANITIZER_USE_GETAUXVAL
 #include <sys/auxv.h>
 #endif

Modified: vendor/compiler-rt/dist/lib/sanitizer_common/sanitizer_platform.h
==============================================================================
--- vendor/compiler-rt/dist/lib/sanitizer_common/sanitizer_platform.h	Sat Jun 10 13:44:29 2017	(r319783)
+++ vendor/compiler-rt/dist/lib/sanitizer_common/sanitizer_platform.h	Sat Jun 10 13:44:32 2017	(r319784)
@@ -269,14 +269,5 @@
 # define SANITIZER_SUPPRESS_LEAK_ON_PTHREAD_EXIT 0
 #endif
 
-#ifndef __GLIBC_PREREQ
-#define __GLIBC_PREREQ(x, y) 0
-#endif
-
-#if SANITIZER_LINUX && __GLIBC_PREREQ(2, 16)
-# define SANITIZER_USE_GETAUXVAL 1
-#else
-# define SANITIZER_USE_GETAUXVAL 0
-#endif
 
 #endif // SANITIZER_PLATFORM_H

Modified: vendor/compiler-rt/dist/lib/sanitizer_common/symbolizer/scripts/build_symbolizer.sh
==============================================================================
--- vendor/compiler-rt/dist/lib/sanitizer_common/symbolizer/scripts/build_symbolizer.sh	Sat Jun 10 13:44:29 2017	(r319783)
+++ vendor/compiler-rt/dist/lib/sanitizer_common/symbolizer/scripts/build_symbolizer.sh	Sat Jun 10 13:44:32 2017	(r319784)
@@ -129,7 +129,7 @@ if [[ ! -d ${LLVM_BUILD} ]]; then
   $LLVM_SRC
 fi
 cd ${LLVM_BUILD}
-ninja LLVMSymbolize LLVMObject LLVMDebugInfoDWARF LLVMSupport LLVMDebugInfoPDB LLVMMC
+ninja LLVMSymbolize LLVMObject LLVMBinaryFormat LLVMDebugInfoDWARF LLVMSupport LLVMDebugInfoPDB LLVMMC
 
 cd ${BUILD_DIR}
 rm -rf ${SYMBOLIZER_BUILD}
@@ -148,6 +148,7 @@ $SCRIPT_DIR/ar_to_bc.sh $LIBCXX_BUILD/lib/libc++.a \
                         $LIBCXX_BUILD/lib/libc++abi.a \
                         $LLVM_BUILD/lib/libLLVMSymbolize.a \
                         $LLVM_BUILD/lib/libLLVMObject.a \
+                        $LLVM_BUILD/lib/libLLVMBinaryFormat.a \
                         $LLVM_BUILD/lib/libLLVMDebugInfoDWARF.a \
                         $LLVM_BUILD/lib/libLLVMSupport.a \
                         $LLVM_BUILD/lib/libLLVMDebugInfoPDB.a \

Modified: vendor/compiler-rt/dist/lib/tsan/rtl/tsan_rtl_thread.cc
==============================================================================
--- vendor/compiler-rt/dist/lib/tsan/rtl/tsan_rtl_thread.cc	Sat Jun 10 13:44:29 2017	(r319783)
+++ vendor/compiler-rt/dist/lib/tsan/rtl/tsan_rtl_thread.cc	Sat Jun 10 13:44:32 2017	(r319784)
@@ -345,6 +345,7 @@ void MemoryAccessRange(ThreadState *thr, uptr pc, uptr
   StatInc(thr, StatMopRange);
 
   if (*shadow_mem == kShadowRodata) {
+    DCHECK(!is_write);
     // Access to .rodata section, no races here.
     // Measurements show that it can be 10-20% of all memory accesses.
     StatInc(thr, StatMopRangeRodata);

Modified: vendor/compiler-rt/dist/test/asan/TestCases/Darwin/atos-symbolizer.cc
==============================================================================
--- vendor/compiler-rt/dist/test/asan/TestCases/Darwin/atos-symbolizer.cc	Sat Jun 10 13:44:29 2017	(r319783)
+++ vendor/compiler-rt/dist/test/asan/TestCases/Darwin/atos-symbolizer.cc	Sat Jun 10 13:44:32 2017	(r319784)
@@ -4,7 +4,7 @@
 // RUN: %env_asan_opts=verbosity=2 ASAN_SYMBOLIZER_PATH=$(which atos) not %run %t 2>&1 | FileCheck %s
 
 // Path returned by `which atos` is invalid on iOS.
-// UNSUPPORTED: ios
+// UNSUPPORTED: ios, i386-darwin
 
 #include <stdlib.h>
 #include <string.h>

Added: vendor/compiler-rt/dist/test/asan/TestCases/Linux/asan_preload_test-3.cc
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ vendor/compiler-rt/dist/test/asan/TestCases/Linux/asan_preload_test-3.cc	Sat Jun 10 13:44:32 2017	(r319784)
@@ -0,0 +1,33 @@
+// Regression test for PR33206
+//
+// RUN: %clang -DDYN=1 -DMALLOC=1 -fPIC -shared %s -o %t-dso1.so
+// RUN: %clang -DDYN=1 -DMALLOC=1 -fPIC -shared %s -o %t-dso2.so %t-dso1.so
+// RUN: %clang %s -o %t-1 %t-dso2.so
+// RUN: env LD_PRELOAD=%shared_libasan %run %t-1 2>&1 | FileCheck %s
+// RUN: %clang -DDYN=1 -DREALLOC=1 -fPIC -shared %s -o %t-dso3.so
+// RUN: %clang -DDYN=1 -DREALLOC=1 -fPIC -shared %s -o %t-dso4.so %t-dso3.so
+// RUN: %clang %s -o %t-2 %t-dso4.so
+// RUN: env LD_PRELOAD=%shared_libasan %run %t-2 2>&1 | FileCheck %s
+// REQUIRES: asan-dynamic-runtime
+
+#include <stdlib.h>
+#include <stdio.h>
+
+#ifdef DYN
+__attribute__((constructor)) void foo() {
+  void *p;
+#ifdef MALLOC
+  p = malloc(1 << 20);
+#endif
+#ifdef REALLOC
+  p = realloc (0, 1 << 20);
+#endif
+  free(p);
+}
+#else
+int main() {
+  // CHECK: Success
+  printf("Success\n");
+  return 0;
+}
+#endif

Modified: vendor/compiler-rt/dist/test/asan/TestCases/Posix/halt_on_error-torture.cc
==============================================================================
--- vendor/compiler-rt/dist/test/asan/TestCases/Posix/halt_on_error-torture.cc	Sat Jun 10 13:44:29 2017	(r319783)
+++ vendor/compiler-rt/dist/test/asan/TestCases/Posix/halt_on_error-torture.cc	Sat Jun 10 13:44:32 2017	(r319784)
@@ -10,12 +10,12 @@
 //
 // Collisions are unlikely but still possible so we need the ||.
 // RUN: rm -f 10.txt
-// RUN: %env_asan_opts=halt_on_error=false:suppress_equal_pcs=false %run %t 10 20 >>10.txt 2>&1 || true
+// RUN: %env_asan_opts=halt_on_error=false:suppress_equal_pcs=false:exitcode=0 %run %t 10 20 2>&1 | cat > 10.txt
 // RUN: FileCheck --check-prefix=CHECK-COLLISION %s < 10.txt || FileCheck --check-prefix=CHECK-NO-COLLISION %s < 10.txt
 //
 // Collisions are unlikely but still possible so we need the ||.
 // RUN: rm -f 20.txt
-// RUN: %env_asan_opts=halt_on_error=false %run %t 10 20 >>20.txt 2>&1 || true
+// RUN: %env_asan_opts=halt_on_error=false:exitcode=0 %run %t 10 20 2>&1 | cat > 20.txt
 // RUN: FileCheck --check-prefix=CHECK-COLLISION %s < 20.txt || FileCheck --check-prefix=CHECK-NO-COLLISION %s < 20.txt
 
 #include <stdio.h>
@@ -38,7 +38,7 @@ void *run(void *arg) {
   unsigned seed = (unsigned)(size_t)arg;
 
   volatile char tmp[2];
-  __asan_poison_memory_region(&tmp, sizeof(tmp)); 
+  __asan_poison_memory_region(&tmp, sizeof(tmp));
 
   for (size_t i = 0; i < niter; ++i) {
     random_delay(&seed);

Added: vendor/compiler-rt/dist/test/msan/Linux/strerror_r.cc
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ vendor/compiler-rt/dist/test/msan/Linux/strerror_r.cc	Sat Jun 10 13:44:32 2017	(r319784)
@@ -0,0 +1,18 @@
+// RUN: %clang_msan -O0 -g %s -o %t && %run %t
+
+#include <assert.h>
+#include <errno.h>
+#include <string.h>
+
+int main() {
+  char buf[1000];
+  char *res = strerror_r(EINVAL, buf, sizeof(buf));
+  assert(res);
+  volatile int z = strlen(res);
+
+  res = strerror_r(-1, buf, sizeof(buf));
+  assert(res);
+  z = strlen(res);
+
+  return 0;
+}

Modified: vendor/compiler-rt/dist/test/profile/Linux/instrprof-alloc.test
==============================================================================
--- vendor/compiler-rt/dist/test/profile/Linux/instrprof-alloc.test	Sat Jun 10 13:44:29 2017	(r319783)
+++ vendor/compiler-rt/dist/test/profile/Linux/instrprof-alloc.test	Sat Jun 10 13:44:32 2017	(r319784)
@@ -1,6 +1,6 @@
-// RUN: %clang_profgen -Xclang -fprofile-instrument=llvm  -fuse-ld=gold -Wl,-wrap,malloc -Wl,-wrap,calloc -o %t -O3 %S/../Inputs/instrprof-alloc.c
+// RUN: %clang_pgogen  -fuse-ld=gold -Wl,-wrap,malloc -Wl,-wrap,calloc -o %t -O3 %S/../Inputs/instrprof-alloc.c
 // RUN: env LLVM_PROFILE_FILE=%t.profraw %run %t
 
-// RUN: %clang_profgen  -Xclang -fprofile-instrument=llvm -mllvm -vp-static-alloc=false -fuse-ld=gold -Wl,-wrap,malloc -Wl,-wrap,calloc -o %t.dyn -O3 %S/../Inputs/instrprof-alloc.c
+// RUN: %clang_pgogen  -mllvm -vp-static-alloc=false -fuse-ld=gold -Wl,-wrap,malloc -Wl,-wrap,calloc -o %t.dyn -O3 %S/../Inputs/instrprof-alloc.c
 // RUN: env LLVM_PROFILE_FILE=%t.profraw not %run %t.dyn
 

Modified: vendor/compiler-rt/dist/test/profile/Linux/instrprof-value-prof-warn.test
==============================================================================
--- vendor/compiler-rt/dist/test/profile/Linux/instrprof-value-prof-warn.test	Sat Jun 10 13:44:29 2017	(r319783)
+++ vendor/compiler-rt/dist/test/profile/Linux/instrprof-value-prof-warn.test	Sat Jun 10 13:44:32 2017	(r319784)
@@ -1,4 +1,4 @@
-RUN: %clang_profgen -O2 -mllvm -disable-vp=false -Xclang -fprofile-instrument=llvm -mllvm -vp-static-alloc=true -DSTRESS=1 -o %t.ir.warn  %S/../Inputs/instrprof-value-prof-real.c
+RUN: %clang_pgogen -O2 -mllvm -disable-vp=false -mllvm -vp-static-alloc=true -DSTRESS=1 -o %t.ir.warn  %S/../Inputs/instrprof-value-prof-real.c
 RUN: env LLVM_PROFILE_FILE=%t.ir.profraw LLVM_VP_MAX_NUM_VALS_PER_SITE=255  %run %t.ir.warn 2>&1 |FileCheck --check-prefix=WARNING %s
 #  Test that enough static counters have been allocated
 RUN: env LLVM_PROFILE_FILE=%t.ir.profraw LLVM_VP_MAX_NUM_VALS_PER_SITE=150  %run %t.ir.warn 2>&1 |FileCheck --check-prefix=NOWARNING --allow-empty %s

Modified: vendor/compiler-rt/dist/test/sanitizer_common/TestCases/sanitizer_coverage_inline8bit_counter.cc
==============================================================================
--- vendor/compiler-rt/dist/test/sanitizer_common/TestCases/sanitizer_coverage_inline8bit_counter.cc	Sat Jun 10 13:44:29 2017	(r319783)
+++ vendor/compiler-rt/dist/test/sanitizer_common/TestCases/sanitizer_coverage_inline8bit_counter.cc	Sat Jun 10 13:44:32 2017	(r319784)
@@ -1,7 +1,7 @@
 // Tests -fsanitize-coverage=inline-8bit-counters
 //
 // REQUIRES: has_sancovcc,stable-runtime
-// UNSUPPORTED: i386-darwin
+// UNSUPPORTED: i386-darwin, x86_64-darwin, x86_64h-darwin
 //
 // RUN: %clangxx -O0 %s -fsanitize-coverage=inline-8bit-counters 2>&1
 

Added: vendor/compiler-rt/dist/test/tsan/strerror_r.cc
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ vendor/compiler-rt/dist/test/tsan/strerror_r.cc	Sat Jun 10 13:44:32 2017	(r319784)
@@ -0,0 +1,29 @@
+// RUN: %clangxx_tsan -O1 -DTEST_ERROR=ERANGE %s -o %t && %run %t 2>&1 | FileCheck --check-prefixes=CHECK,CHECK-SYS %s
+// RUN: %clangxx_tsan -O1 -DTEST_ERROR=-1 %s -o %t && not %run %t 2>&1 | FileCheck --check-prefixes=CHECK,CHECK-USER %s
+// UNSUPPORTED: darwin
+
+#include <assert.h>
+#include <errno.h>
+#include <pthread.h>
+#include <stdio.h>
+#include <string.h>
+
+char buffer[1000];
+
+void *Thread(void *p) {
+  return strerror_r(TEST_ERROR, buffer, sizeof(buffer));
+}
+
+int main() {
+  pthread_t th[2];
+  pthread_create(&th[0], 0, Thread, 0);
+  pthread_create(&th[1], 0, Thread, 0);
+  pthread_join(th[0], 0);
+  pthread_join(th[1], 0);
+  fprintf(stderr, "DONE\n");
+}
+
+// CHECK-USER: WARNING: ThreadSanitizer: data race
+// CHECK-SYS-NOT: WARNING: ThreadSanitizer: data race
+
+// CHECK: DONE



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201706101344.v5ADiWx2094820>