Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(375)

Unified Diff: Source/wtf/PartitionAllocTest.cpp

Issue 1314843008: Make PartitionAllocDeathTest.GuardPages pass on Win64. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: posix Created 5 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/wtf/PartitionAllocTest.cpp
diff --git a/Source/wtf/PartitionAllocTest.cpp b/Source/wtf/PartitionAllocTest.cpp
index 17aa9e985824b3814a0cc0480a0b03bd99923453..996c085d357b6a7c72fbb70e4c01e7ff61a20eee 100644
--- a/Source/wtf/PartitionAllocTest.cpp
+++ b/Source/wtf/PartitionAllocTest.cpp
@@ -1320,10 +1320,25 @@ TEST(PartitionAllocDeathTest, GuardPages)
{
TestSetup();
- // This large size will result in a direct mapped allocation with guard
- // pages at either end.
- size_t size = (kGenericMaxBucketed + kSystemPageSize) - kExtraAllocSize;
+ // partitionAlloc adds kPartitionPageSize to the requested size
+ // (for metadata), and then rounds that size to kPageAllocationGranularity.
+ // To be able to reliably write one past a direct allocation, choose a size
+ // that's
+ // a) larger than kGenericMaxBucketed (to make the allocation direct)
+ // b) aligned at kPageAllocationGranularity boundaries after
+ // kPartitionPageSize has been added to it.
+ // (On 32-bit, partitionAlloc adds another kSystemPageSize to the
+ // allocation size before rounding, but there it marks the memory right
+ // after size as inaccessible, so it's fine to write 1 past the size we
+ // hand to partitionAlloc and we don't need to worry about allocation
+ // granularities.)
+#define ALIGN(N, A) (((N) + (A) - 1) / (A) * (A))
+ const int kSize = ALIGN(kGenericMaxBucketed + 1 + kPartitionPageSize, kPageAllocationGranularity) - kPartitionPageSize;
+#undef ALIGN
+ static_assert(kSize > kGenericMaxBucketed, "allocation not large enough for direct allocation");
+ size_t size = kSize - kExtraAllocSize;
void* ptr = partitionAllocGeneric(genericAllocator.root(), size);
+
EXPECT_TRUE(ptr);
char* charPtr = reinterpret_cast<char*>(ptr) - kPointerOffset;
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698