[PATCH] Fixes in LargeMmapAllocator::GetBlockBegin().

Sergey Matveev earthdok at google.com
Thu Apr 4 12:58:59 PDT 2013


    - regression test for meta-regions

Hi kcc, glider, samsonov,

http://llvm-reviews.chandlerc.com/D624

CHANGE SINCE LAST DIFF
  http://llvm-reviews.chandlerc.com/D624?vs=1507&id=1510#toc

Files:
  lib/sanitizer_common/sanitizer_allocator.h
  lib/sanitizer_common/tests/sanitizer_allocator_test.cc

Index: lib/sanitizer_common/sanitizer_allocator.h
===================================================================
--- lib/sanitizer_common/sanitizer_allocator.h
+++ lib/sanitizer_common/sanitizer_allocator.h
@@ -1014,7 +1014,9 @@
     CHECK_GE(nearest_chunk, h->map_beg);
     CHECK_LT(nearest_chunk, h->map_beg + h->map_size);
     CHECK_LE(nearest_chunk, p);
-    if (h->map_beg + h->map_size < p)
+    if (h->map_beg + h->map_size <= p)
+      return 0;
+    if (h->map_beg + page_size_ > p)
       return 0;
     return GetUser(h);
   }
Index: lib/sanitizer_common/tests/sanitizer_allocator_test.cc
===================================================================
--- lib/sanitizer_common/tests/sanitizer_allocator_test.cc
+++ lib/sanitizer_common/tests/sanitizer_allocator_test.cc
@@ -284,6 +284,8 @@
   for (int i = 0; i < kNumAllocs; i++) {
     allocated[i] = (char *)a.Allocate(&stats, size, 1);
     CHECK(a.PointerIsMine(allocated[i]));
+    // Meta-regions should not be accepted by PointerIsMine.
+    CHECK(!a.PointerIsMine(allocated[i] - 1));
   }
   // Deallocate all.
   CHECK_GT(a.TotalMemoryUsed(), size * kNumAllocs);
@@ -629,7 +631,6 @@
   TestSizeClassAllocatorIteration<Allocator32Compact>();
 }
 
-
 TEST(SanitizerCommon, LargeMmapAllocatorIteration) {
   LargeMmapAllocator<> a;
   a.Init();
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D624.2.patch
Type: text/x-patch
Size: 1324 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20130404/6d477b95/attachment.bin>


More information about the llvm-commits mailing list