[compiler-rt] r291560 - Revert r291509, 291510 and 291511

Diana Picus via llvm-commits llvm-commits at lists.llvm.org
Tue Jan 10 03:14:44 PST 2017


Author: rovka
Date: Tue Jan 10 05:14:44 2017
New Revision: 291560

URL: http://llvm.org/viewvc/llvm-project?rev=291560&view=rev
Log:
Revert r291509, 291510 and 291511

Revert "ASAN activate/deactive controls thread_local_quarantine_size_kb option."
Revert "Bypass quarantine when quarantine size is set ot zero."
Revert "ASAN activate/deactive controls thread_local_quarantine_size_kb option."

One of these commits broke some of the ARM / AArch64 buildbots:
TEST 'AddressSanitizer-aarch64-linux :: TestCases/Posix/start-deactivated.cc' FAILED

Command Output (stderr):
--
/home/buildslave/buildslave/clang-cmake-aarch64-42vma/llvm/projects/compiler-rt/test/asan/TestCases/Posix/start-deactivated.cc:85:12: error: expected string not found in input
 // CHECK: WARNING: AddressSanitizer failed to allocate 0xfff{{.*}} bytes
           ^
<stdin>:1:1: note: scanning from here
start-deactivated.cc.tmp: /home/buildslave/buildslave/clang-cmake-aarch64-42vma/llvm/projects/compiler-rt/test/asan/TestCases/Posix/start-deactivated.cc:40: void test_malloc_shadow(char *, size_t, bool): Assertion `(char *)__asan_region_is_poisoned(p - 1, sz + 1) == (expect_redzones ? p - 1 : nullptr)' failed.
^
<stdin>:2:1: note: possible intended match here
Error: Aborted (core dumped)
^

Modified:
    compiler-rt/trunk/lib/asan/asan_activation.cc
    compiler-rt/trunk/lib/asan/asan_activation_flags.inc
    compiler-rt/trunk/lib/asan/asan_flags.cc
    compiler-rt/trunk/lib/sanitizer_common/sanitizer_quarantine.h
    compiler-rt/trunk/test/asan/TestCases/Linux/thread_local_quarantine_size_kb.cc

Modified: compiler-rt/trunk/lib/asan/asan_activation.cc
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/asan/asan_activation.cc?rev=291560&r1=291559&r2=291560&view=diff
==============================================================================
--- compiler-rt/trunk/lib/asan/asan_activation.cc (original)
+++ compiler-rt/trunk/lib/asan/asan_activation.cc Tue Jan 10 05:14:44 2017
@@ -77,13 +77,12 @@ static struct AsanDeactivatedFlags {
 
   void Print() {
     Report(
-        "quarantine_size_mb %d, thread_local_quarantine_size_kb %d, "
-        "max_redzone %d, poison_heap %d, malloc_context_size %d, "
-        "alloc_dealloc_mismatch %d, allocator_may_return_null %d, coverage %d, "
-        "coverage_dir %s, allocator_release_to_os_interval_ms %d\n",
-        allocator_options.quarantine_size_mb,
-        allocator_options.thread_local_quarantine_size_kb,
-        allocator_options.max_redzone, poison_heap, malloc_context_size,
+        "quarantine_size_mb %d, max_redzone %d, poison_heap %d, "
+        "malloc_context_size %d, alloc_dealloc_mismatch %d, "
+        "allocator_may_return_null %d, coverage %d, coverage_dir %s, "
+        "allocator_release_to_os_interval_ms %d\n",
+        allocator_options.quarantine_size_mb, allocator_options.max_redzone,
+        poison_heap, malloc_context_size,
         allocator_options.alloc_dealloc_mismatch,
         allocator_options.may_return_null, coverage, coverage_dir,
         allocator_options.release_to_os_interval_ms);
@@ -110,7 +109,6 @@ void AsanDeactivate() {
 
   AllocatorOptions disabled = asan_deactivated_flags.allocator_options;
   disabled.quarantine_size_mb = 0;
-  disabled.thread_local_quarantine_size_kb = 0;
   disabled.min_redzone = 16;  // Redzone must be at least 16 bytes long.
   disabled.max_redzone = 16;
   disabled.alloc_dealloc_mismatch = false;

Modified: compiler-rt/trunk/lib/asan/asan_activation_flags.inc
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/asan/asan_activation_flags.inc?rev=291560&r1=291559&r2=291560&view=diff
==============================================================================
--- compiler-rt/trunk/lib/asan/asan_activation_flags.inc (original)
+++ compiler-rt/trunk/lib/asan/asan_activation_flags.inc Tue Jan 10 05:14:44 2017
@@ -24,7 +24,6 @@
 ASAN_ACTIVATION_FLAG(int, redzone)
 ASAN_ACTIVATION_FLAG(int, max_redzone)
 ASAN_ACTIVATION_FLAG(int, quarantine_size_mb)
-ASAN_ACTIVATION_FLAG(int, thread_local_quarantine_size_kb)
 ASAN_ACTIVATION_FLAG(bool, alloc_dealloc_mismatch)
 ASAN_ACTIVATION_FLAG(bool, poison_heap)
 

Modified: compiler-rt/trunk/lib/asan/asan_flags.cc
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/asan/asan_flags.cc?rev=291560&r1=291559&r2=291560&view=diff
==============================================================================
--- compiler-rt/trunk/lib/asan/asan_flags.cc (original)
+++ compiler-rt/trunk/lib/asan/asan_flags.cc Tue Jan 10 05:14:44 2017
@@ -169,11 +169,6 @@ void InitializeFlags() {
         (ASAN_LOW_MEMORY) ? 1 << 6 : FIRST_32_SECOND_64(1 << 8, 1 << 10);
     f->thread_local_quarantine_size_kb = kDefaultThreadLocalQuarantineSizeKb;
   }
-  if (f->thread_local_quarantine_size_kb == 0 && f->quarantine_size_mb > 0) {
-    Report("%s: thread_local_quarantine_size_kb can be set to 0 only when "
-           "quarantine_size_mb is set to 0\n", SanitizerToolName);
-    Die();
-  }
   if (!f->replace_str && common_flags()->intercept_strlen) {
     Report("WARNING: strlen interceptor is enabled even though replace_str=0. "
            "Use intercept_strlen=0 to disable it.");

Modified: compiler-rt/trunk/lib/sanitizer_common/sanitizer_quarantine.h
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/sanitizer_common/sanitizer_quarantine.h?rev=291560&r1=291559&r2=291560&view=diff
==============================================================================
--- compiler-rt/trunk/lib/sanitizer_common/sanitizer_quarantine.h (original)
+++ compiler-rt/trunk/lib/sanitizer_common/sanitizer_quarantine.h Tue Jan 10 05:14:44 2017
@@ -49,31 +49,18 @@ class Quarantine {
   }
 
   void Init(uptr size, uptr cache_size) {
-    // Thread local quarantine size can be zero only when global quarantine size
-    // is zero (it allows us to perform just one atomic read per Put() call).
-    CHECK((size == 0 && cache_size == 0) || cache_size != 0);
-
-    atomic_store(&max_size_, size, memory_order_relaxed);
+    atomic_store(&max_size_, size, memory_order_release);
     atomic_store(&min_size_, size / 10 * 9,
-                 memory_order_relaxed);  // 90% of max size.
-    atomic_store(&max_cache_size_, cache_size, memory_order_relaxed);
+                 memory_order_release); // 90% of max size.
+    max_cache_size_ = cache_size;
   }
 
-  uptr GetSize() const { return atomic_load(&max_size_, memory_order_relaxed); }
-  uptr GetCacheSize() const {
-    return atomic_load(&max_cache_size_, memory_order_relaxed);
-  }
+  uptr GetSize() const { return atomic_load(&max_size_, memory_order_acquire); }
+  uptr GetCacheSize() const { return max_cache_size_; }
 
   void Put(Cache *c, Callback cb, Node *ptr, uptr size) {
-    uptr cache_size = GetCacheSize();
-    if (cache_size) {
-      c->Enqueue(cb, ptr, size);
-    } else {
-      // cache_size == 0 only when size == 0 (see Init).
-      cb.Recycle(ptr);
-    }
-    // Check cache size anyway to accommodate for runtime cache_size change.
-    if (c->Size() > cache_size)
+    c->Enqueue(cb, ptr, size);
+    if (c->Size() > max_cache_size_)
       Drain(c, cb);
   }
 
@@ -96,7 +83,7 @@ class Quarantine {
   char pad0_[kCacheLineSize];
   atomic_uintptr_t max_size_;
   atomic_uintptr_t min_size_;
-  atomic_uintptr_t max_cache_size_;
+  uptr max_cache_size_;
   char pad1_[kCacheLineSize];
   SpinMutex cache_mutex_;
   SpinMutex recycle_mutex_;
@@ -105,7 +92,7 @@ class Quarantine {
 
   void NOINLINE Recycle(Callback cb) {
     Cache tmp;
-    uptr min_size = atomic_load(&min_size_, memory_order_relaxed);
+    uptr min_size = atomic_load(&min_size_, memory_order_acquire);
     {
       SpinMutexLock l(&cache_mutex_);
       while (cache_.Size() > min_size) {
@@ -218,7 +205,6 @@ class QuarantineCache {
     return b;
   }
 };
-
 } // namespace __sanitizer
 
 #endif // SANITIZER_QUARANTINE_H

Modified: compiler-rt/trunk/test/asan/TestCases/Linux/thread_local_quarantine_size_kb.cc
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/test/asan/TestCases/Linux/thread_local_quarantine_size_kb.cc?rev=291560&r1=291559&r2=291560&view=diff
==============================================================================
--- compiler-rt/trunk/test/asan/TestCases/Linux/thread_local_quarantine_size_kb.cc (original)
+++ compiler-rt/trunk/test/asan/TestCases/Linux/thread_local_quarantine_size_kb.cc Tue Jan 10 05:14:44 2017
@@ -5,10 +5,8 @@
 // RUN:   FileCheck %s --check-prefix=CHECK-VALUE
 // RUN: %env_asan_opts=thread_local_quarantine_size_kb=64:quarantine_size_mb=64 %run %t 2>&1 | \
 // RUN:   FileCheck %s --allow-empty --check-prefix=CHECK-SMALL-LOCAL-CACHE-SMALL-OVERHEAD
-// RUN: %env_asan_opts=thread_local_quarantine_size_kb=0:quarantine_size_mb=0 %run %t 2>&1 | \
-// RUN:   FileCheck %s --check-prefix=CHECK-QUARANTINE-DISABLED
-// RUN: %env_asan_opts=thread_local_quarantine_size_kb=0:quarantine_size_mb=64 not %run %t 2>&1 | \
-// RUN:   FileCheck %s --check-prefix=CHECK-FOR-PARAMETER-ERROR
+// RUN: %env_asan_opts=thread_local_quarantine_size_kb=0:quarantine_size_mb=64 %run %t 2>&1 | \
+// RUN:   FileCheck %s --check-prefix=CHECK-NO-LOCAL-CACHE-HUGE-OVERHEAD
 
 #include <stdio.h>
 #include <stdlib.h>
@@ -39,5 +37,4 @@ int main() {
 
 // CHECK-VALUE: thread_local_quarantine_size_kb=256K
 // CHECK-SMALL-LOCAL-CACHE-SMALL-OVERHEAD-NOT: Heap size limit exceeded
-// CHECK-QUARANTINE-DISABLED-NOT: Heap size limit exceeded
-// CHECK-FOR-PARAMETER-ERROR: thread_local_quarantine_size_kb can be set to 0 only when quarantine_size_mb is set to 0
+// CHECK-NO-LOCAL-CACHE-HUGE-OVERHEAD: Heap size limit exceeded




More information about the llvm-commits mailing list