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

Unified Diff: Source/wtf/PartitionAllocTest.cpp

Issue 645223007: PartitionAlloc: Leave bucket in valid state when allocation fails (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: add fix Created 6 years, 2 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 | « Source/wtf/PartitionAlloc.cpp ('k') | 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 7adc14a566f339f2e3d63fd5062b2d0f94f0a692..c1f2f2a5bdedd732066e19fe16741a23bc262420 100644
--- a/Source/wtf/PartitionAllocTest.cpp
+++ b/Source/wtf/PartitionAllocTest.cpp
@@ -1097,6 +1097,35 @@ TEST(PartitionAllocTest, LostFreePagesBug)
TestShutdown();
}
+// Tests that if an allocation fails in "return null" mode, repeating it doesn't
+// crash, and still returns null. The test allocates 6 GB of memory in 512 kB
+// blocks. This may never fail on 64-bit systems, in which case this test fails
Jens Widell 2014/10/22 19:40:12 To make these allocations fail on 64-bit, I've bee
+// to test what it sets out to test.
+TEST(PartitionAllocTest, RepeatedReturnNull)
+{
+ TestSetup();
+
+ void* ptrs[8192];
+ int i;
+
+ for (i = 0; i < 6144; ++i) {
+ ptrs[i] = partitionAllocGenericFlags(genericAllocator.root(), WTF::PartitionAllocReturnNull, 512*1024);
+ if (!ptrs[i]) {
+ ptrs[i] = partitionAllocGenericFlags(genericAllocator.root(), WTF::PartitionAllocReturnNull, 512*1024);
+ EXPECT_FALSE(ptrs[i]);
+ break;
+ }
+ }
+
+ for (--i; i >= 0; --i) {
+ partitionFreeGeneric(genericAllocator.root(), ptrs[i]);
+ ptrs[i] = partitionAllocGenericFlags(genericAllocator.root(), WTF::PartitionAllocReturnNull, 512*1024);
+ partitionFreeGeneric(genericAllocator.root(), ptrs[i]);
+ }
+
+ TestShutdown();
+}
+
#if !OS(ANDROID)
// Make sure that malloc(-1) dies.
« no previous file with comments | « Source/wtf/PartitionAlloc.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698