diff options
author | Kostya Serebryany <kcc@google.com> | 2015-01-07 02:37:52 +0000 |
---|---|---|
committer | Kostya Serebryany <kcc@google.com> | 2015-01-07 02:37:52 +0000 |
commit | c26d26c3f3cde1121cb8f081c991fca8973d28bc (patch) | |
tree | 1914ef006a0fa169e07e4d65f94a8853e818f8be /lib | |
parent | b3793db6a5060ab98be7f01a5d9e8247e95f4261 (diff) |
[asan] add flag quarantine_size_mb, deprecate quarantine_size
git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@225337 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib')
-rw-r--r-- | lib/asan/asan_allocator.cc | 4 | ||||
-rw-r--r-- | lib/asan/asan_flags.cc | 13 | ||||
-rw-r--r-- | lib/asan/asan_flags.inc | 6 | ||||
-rw-r--r-- | lib/asan/asan_rtl.cc | 2 |
4 files changed, 20 insertions, 5 deletions
diff --git a/lib/asan/asan_allocator.cc b/lib/asan/asan_allocator.cc index 9525cf536..fd63ac68c 100644 --- a/lib/asan/asan_allocator.cc +++ b/lib/asan/asan_allocator.cc @@ -206,7 +206,7 @@ QuarantineCache *GetQuarantineCache(AsanThreadLocalMallocStorage *ms) { } void AllocatorOptions::SetFrom(const Flags *f, const CommonFlags *cf) { - quarantine_size_mb = f->quarantine_size >> 20; + quarantine_size_mb = f->quarantine_size_mb; min_redzone = f->redzone; max_redzone = f->max_redzone; may_return_null = cf->allocator_may_return_null; @@ -214,7 +214,7 @@ void AllocatorOptions::SetFrom(const Flags *f, const CommonFlags *cf) { } void AllocatorOptions::CopyTo(Flags *f, CommonFlags *cf) { - f->quarantine_size = (int)quarantine_size_mb << 20; + f->quarantine_size_mb = quarantine_size_mb; f->redzone = min_redzone; f->max_redzone = max_redzone; cf->allocator_may_return_null = may_return_null; diff --git a/lib/asan/asan_flags.cc b/lib/asan/asan_flags.cc index d6144a7a6..2c2d5c8f1 100644 --- a/lib/asan/asan_flags.cc +++ b/lib/asan/asan_flags.cc @@ -64,6 +64,7 @@ void InitializeFlags(Flags *f) { OverrideCommonFlags(cf); } + const int kDefaultQuarantineSizeMb = (ASAN_LOW_MEMORY) ? 1UL << 6 : 1UL << 8; f->SetDefaults(); // Override from compile definition. @@ -118,6 +119,18 @@ void InitializeFlags(Flags *f) { CHECK_LE(f->max_redzone, 2048); CHECK(IsPowerOfTwo(f->redzone)); CHECK(IsPowerOfTwo(f->max_redzone)); + + // quarantine_size is deprecated but we still honor it. + // quarantine_size can not be used together with quarantine_size_mb. + if (f->quarantine_size >= 0 && f->quarantine_size_mb >= 0) { + Report("%s: please use either 'quarantine_size' (deprecated) or " + "quarantine_size_mb, but not both\n", SanitizerToolName); + Die(); + } + if (f->quarantine_size >= 0) + f->quarantine_size_mb = f->quarantine_size >> 20; + if (f->quarantine_size_mb < 0) + f->quarantine_size_mb = kDefaultQuarantineSizeMb; } } // namespace __asan diff --git a/lib/asan/asan_flags.inc b/lib/asan/asan_flags.inc index 066b47aec..ec9d41980 100644 --- a/lib/asan/asan_flags.inc +++ b/lib/asan/asan_flags.inc @@ -17,8 +17,10 @@ // ASAN_FLAG(Type, Name, DefaultValue, Description) // See COMMON_FLAG in sanitizer_flags.inc for more details. -ASAN_FLAG(int, quarantine_size, (ASAN_LOW_MEMORY) ? 1UL << 26 : 1UL << 28, - "Size (in bytes) of quarantine used to detect use-after-free " +ASAN_FLAG(int, quarantine_size, -1, + "Deprecated, please use quarantine_size_mb.") +ASAN_FLAG(int, quarantine_size_mb, -1, + "Size (in Mb) of quarantine used to detect use-after-free " "errors. Lower value may reduce memory usage but increase the " "chance of false negatives.") ASAN_FLAG(int, redzone, 16, diff --git a/lib/asan/asan_rtl.cc b/lib/asan/asan_rtl.cc index 9d994885e..db258e73e 100644 --- a/lib/asan/asan_rtl.cc +++ b/lib/asan/asan_rtl.cc @@ -281,7 +281,7 @@ static void PrintAddressSpaceLayout() { Printf("\n"); Printf("redzone=%zu\n", (uptr)flags()->redzone); Printf("max_redzone=%zu\n", (uptr)flags()->max_redzone); - Printf("quarantine_size=%zuM\n", (uptr)flags()->quarantine_size >> 20); + Printf("quarantine_size_mb=%zuM\n", (uptr)flags()->quarantine_size_mb); Printf("malloc_context_size=%zu\n", (uptr)common_flags()->malloc_context_size); |