[PATCH] Fixes in LargeMmapAllocator::GetBlockBegin().
Sergey Matveev
earthdok at google.com
Fri Apr 5 19:57:38 PDT 2013
- reverted one change and added a test for the other
Hi kcc, glider, samsonov,
http://llvm-reviews.chandlerc.com/D624
CHANGE SINCE LAST DIFF
http://llvm-reviews.chandlerc.com/D624?vs=1510&id=1539#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,7 @@
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;
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
@@ -337,6 +337,13 @@
a.Deallocate(&stats, allocated[i]);
}
}
+
+ // Regression test for boundary condition in GetBlockBegin().
+ uptr page_size = GetPageSizeCached();
+ char *p = (char *)a.Allocate(&stats, page_size, 1);
+ CHECK_EQ(p, a.GetBlockBegin(p));
+ CHECK_NE(p, (char *)a.GetBlockBegin(p) + page_size);
+ a.Deallocate(&stats, p);
}
template
@@ -629,7 +636,6 @@
TestSizeClassAllocatorIteration<Allocator32Compact>();
}
-
TEST(SanitizerCommon, LargeMmapAllocatorIteration) {
LargeMmapAllocator<> a;
a.Init();
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D624.3.patch
Type: text/x-patch
Size: 1292 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20130405/53ec8eb6/attachment.bin>
More information about the llvm-commits
mailing list