diff options
| -rw-r--r-- | compiler-rt/lib/asan/asan_allocator.cc | 10 | ||||
| -rw-r--r-- | compiler-rt/lib/asan/asan_rtl.cc | 11 | ||||
| -rw-r--r-- | compiler-rt/lib/asan/tests/asan_test.cc | 10 | ||||
| -rw-r--r-- | compiler-rt/lib/asan/tests/asan_test_config.h | 4 |
4 files changed, 30 insertions, 5 deletions
diff --git a/compiler-rt/lib/asan/asan_allocator.cc b/compiler-rt/lib/asan/asan_allocator.cc index 7eadec5a3bc..3573f20cacc 100644 --- a/compiler-rt/lib/asan/asan_allocator.cc +++ b/compiler-rt/lib/asan/asan_allocator.cc @@ -43,10 +43,16 @@ namespace __asan { #define REDZONE FLAG_redzone static const size_t kMinAllocSize = REDZONE * 2; -static const size_t kMinMmapSize = 4UL << 20; // 4M static const uint64_t kMaxAvailableRam = 128ULL << 30; // 128G static const size_t kMaxThreadLocalQuarantine = 1 << 20; // 1M -static const size_t kMaxSizeForThreadLocalFreeList = 1 << 17; + +#if ASAN_LOW_MEMORY==1 +static const size_t kMinMmapSize = 4UL << 17; // 128K + static const size_t kMaxSizeForThreadLocalFreeList = 1 << 15; // 32K +#else +static const size_t kMinMmapSize = 4UL << 20; // 4M + static const size_t kMaxSizeForThreadLocalFreeList = 1 << 17; // 128K +#endif // Size classes less than kMallocSizeClassStep are powers of two. // All other size classes are multiples of kMallocSizeClassStep. diff --git a/compiler-rt/lib/asan/asan_rtl.cc b/compiler-rt/lib/asan/asan_rtl.cc index 70e4383ce52..f0e603fa951 100644 --- a/compiler-rt/lib/asan/asan_rtl.cc +++ b/compiler-rt/lib/asan/asan_rtl.cc @@ -419,7 +419,15 @@ void __asan_init() { FLAG_v = IntFlagValue(options, "verbosity=", 0); +#if ASAN_LOW_MEMORY == 1 + FLAG_quarantine_size = + IntFlagValue(options, "quarantine_size=", 1UL << 24); // 16M + FLAG_redzone = IntFlagValue(options, "redzone=", 64); +#else + FLAG_quarantine_size = + IntFlagValue(options, "quarantine_size=", 1UL << 28); // 256M FLAG_redzone = IntFlagValue(options, "redzone=", 128); +#endif CHECK(FLAG_redzone >= 32); CHECK((FLAG_redzone & (FLAG_redzone - 1)) == 0); @@ -443,9 +451,6 @@ void __asan_init() { atexit(asan_atexit); } - FLAG_quarantine_size = - IntFlagValue(options, "quarantine_size=", 1UL << 28); - // interceptors InitializeAsanInterceptors(); diff --git a/compiler-rt/lib/asan/tests/asan_test.cc b/compiler-rt/lib/asan/tests/asan_test.cc index 8bd4eb13c77..c59c04566ac 100644 --- a/compiler-rt/lib/asan/tests/asan_test.cc +++ b/compiler-rt/lib/asan/tests/asan_test.cc @@ -453,7 +453,11 @@ static void MallocStress(size_t n) { } TEST(AddressSanitizer, MallocStressTest) { +#if ASAN_LOW_MEMORY==1 + MallocStress(20000); +#else MallocStress(200000); +#endif } static void TestLargeMalloc(size_t size) { @@ -468,6 +472,7 @@ TEST(AddressSanitizer, LargeMallocTest) { } } +#if ASAN_LOW_MEMORY != 1 TEST(AddressSanitizer, HugeMallocTest) { #ifdef __APPLE__ // It was empirically found out that 1215 megabytes is the maximum amount of @@ -480,12 +485,17 @@ TEST(AddressSanitizer, HugeMallocTest) { #endif TestLargeMalloc(n_megs << 20); } +#endif TEST(AddressSanitizer, ThreadedMallocStressTest) { const int kNumThreads = 4; pthread_t t[kNumThreads]; for (int i = 0; i < kNumThreads; i++) { +#if ASAN_LOW_MEMORY==1 + pthread_create(&t[i], 0, (void* (*)(void *x))MallocStress, (void*)10000); +#else pthread_create(&t[i], 0, (void* (*)(void *x))MallocStress, (void*)100000); +#endif } for (int i = 0; i < kNumThreads; i++) { pthread_join(t[i], 0); diff --git a/compiler-rt/lib/asan/tests/asan_test_config.h b/compiler-rt/lib/asan/tests/asan_test_config.h index de4ae95bd24..6cf0e695848 100644 --- a/compiler-rt/lib/asan/tests/asan_test_config.h +++ b/compiler-rt/lib/asan/tests/asan_test_config.h @@ -39,6 +39,10 @@ using std::map; # error "please define ASAN_NEEDS_SEGV" #endif +#ifndef ASAN_LOW_MEMORY +#define ASAN_LOW_MEMORY 0 +#endif + #define ASAN_PCRE_DOTALL "" #endif // ASAN_TEST_CONFIG_H |

