From: Kostya Serebryany Date: Wed, 19 Dec 2012 06:51:45 +0000 (+0000) Subject: [sanitizer] one more stability fix in 64-bit allocator X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=2abbce67019365d397ceba0cbebdc7d3dad75df6;p=platform%2Fupstream%2Fllvm.git [sanitizer] one more stability fix in 64-bit allocator llvm-svn: 170498 --- diff --git a/compiler-rt/lib/sanitizer_common/sanitizer_allocator.h b/compiler-rt/lib/sanitizer_common/sanitizer_allocator.h index 7a97cc9..87a7fc1 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 bb239f9..9a4e6e2 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 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;