summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--compiler-rt/lib/sanitizer_common/sanitizer_allocator.h3
-rw-r--r--compiler-rt/lib/sanitizer_common/tests/sanitizer_allocator_test.cc7
2 files changed, 6 insertions, 4 deletions
diff --git a/compiler-rt/lib/sanitizer_common/sanitizer_allocator.h b/compiler-rt/lib/sanitizer_common/sanitizer_allocator.h
index 7a97cc9f443..87a7fc1aaa2 100644
--- a/compiler-rt/lib/sanitizer_common/sanitizer_allocator.h
+++ b/compiler-rt/lib/sanitizer_common/sanitizer_allocator.h
@@ -297,7 +297,7 @@ class SizeClassAllocator64 {
uptr beg_idx = region->allocated_user;
uptr end_idx = beg_idx + kPopulateSize;
uptr region_beg = kSpaceBeg + kRegionSize * class_id;
- if (Max(end_idx, beg_idx + size) > region->mapped_user) {
+ if (end_idx + size > region->mapped_user) {
// Do the mmap for the user memory.
CHECK_GT(region->mapped_user + kUserMapSize, end_idx);
MapWithCallback(region_beg + region->mapped_user, kUserMapSize);
@@ -312,6 +312,7 @@ class SizeClassAllocator64 {
i++;
} while (idx < end_idx);
region->allocated_user += idx - beg_idx;
+ CHECK_LE(region->allocated_user, region->mapped_user);
region->allocated_meta += i * kMetadataSize;
if (region->allocated_meta > region->mapped_meta) {
// Do the mmap for the metadata.
diff --git a/compiler-rt/lib/sanitizer_common/tests/sanitizer_allocator_test.cc b/compiler-rt/lib/sanitizer_common/tests/sanitizer_allocator_test.cc
index bb239f9de9e..9a4e6e23f38 100644
--- a/compiler-rt/lib/sanitizer_common/tests/sanitizer_allocator_test.cc
+++ b/compiler-rt/lib/sanitizer_common/tests/sanitizer_allocator_test.cc
@@ -85,18 +85,19 @@ void TestSizeClassAllocator() {
a->Init();
static const uptr sizes[] = {1, 16, 30, 40, 100, 1000, 10000,
- 50000, 60000, 100000, 300000, 500000, 1000000, 2000000};
+ 50000, 60000, 100000, 120000, 300000, 500000, 1000000, 2000000};
std::vector<void *> allocated;
uptr last_total_allocated = 0;
- for (int i = 0; i < 5; i++) {
+ for (int i = 0; i < 3; i++) {
// Allocate a bunch of chunks.
for (uptr s = 0; s < ARRAY_SIZE(sizes); s++) {
uptr size = sizes[s];
if (!a->CanAllocate(size, 1)) continue;
// printf("s = %ld\n", size);
- uptr n_iter = std::max((uptr)6, 1000000 / size);
+ uptr n_iter = std::max((uptr)6, 10000000 / size);
+ // fprintf(stderr, "size: %ld iter: %ld\n", size, n_iter);
for (uptr i = 0; i < n_iter; i++) {
char *x = (char*)a->Allocate(size, 1);
x[0] = 0;
OpenPOWER on IntegriCloud