summaryrefslogtreecommitdiff
path: root/lib/sanitizer_common/sanitizer_quarantine.h
diff options
context:
space:
mode:
authorDiana Picus <diana.picus@linaro.org>2017-01-10 11:14:44 +0000
committerDiana Picus <diana.picus@linaro.org>2017-01-10 11:14:44 +0000
commit131c40c702f16aa044550f6f8d77e2a16ac7c4cf (patch)
tree0ce0326b7c45c715df52489f24e28fc3289ab2df /lib/sanitizer_common/sanitizer_quarantine.h
parent9f93113ee5c1cc0fbbb8a5386e30df333924de83 (diff)
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) ^ git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@291560 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/sanitizer_common/sanitizer_quarantine.h')
-rw-r--r--lib/sanitizer_common/sanitizer_quarantine.h32
1 files changed, 9 insertions, 23 deletions
diff --git a/lib/sanitizer_common/sanitizer_quarantine.h b/lib/sanitizer_common/sanitizer_quarantine.h
index 1a0d9545b..3d74ef2b6 100644
--- a/lib/sanitizer_common/sanitizer_quarantine.h
+++ b/lib/sanitizer_common/sanitizer_quarantine.h
@@ -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