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

Unified Diff: Source/wtf/PartitionAlloc.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: avoid integer overflow on 32-bit systems Created 6 years, 1 month 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 | Source/wtf/PartitionAllocTest.cpp » ('j') | Source/wtf/PartitionAllocTest.cpp » ('J')
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/wtf/PartitionAlloc.cpp
diff --git a/Source/wtf/PartitionAlloc.cpp b/Source/wtf/PartitionAlloc.cpp
index ab14a4328f122cd7b2e7b56e31c6fc83aadc98c6..1ef1c752f6464c4e8b72cbd520c7a507fa379d92 100644
--- a/Source/wtf/PartitionAlloc.cpp
+++ b/Source/wtf/PartitionAlloc.cpp
@@ -699,8 +699,13 @@ void* partitionAllocSlowPath(PartitionRootBase* root, int flags, size_t size, Pa
return partitionPageAllocAndFillFreelist(newPage);
partitionAllocSlowPathFailed:
- if (returnNull)
+ if (returnNull) {
+ // If we get here, we will set the active page to null, which is an
+ // invalid state. To support continued use of this bucket, we need to
+ // restore a valid state, by setting the active page to the seed page.
+ bucket->activePagesHead = &PartitionRootGeneric::gSeedPage;
return nullptr;
+ }
partitionOutOfMemory();
return nullptr;
}
@@ -763,7 +768,6 @@ void partitionFreeSlowPath(PartitionPage* page)
{
PartitionBucket* bucket = page->bucket;
ASSERT(page != &PartitionRootGeneric::gSeedPage);
- ASSERT(bucket->activePagesHead != &PartitionRootGeneric::gSeedPage);
if (LIKELY(page->numAllocatedSlots == 0)) {
// Page became fully unused.
if (UNLIKELY(partitionBucketIsDirectMapped(bucket))) {
@@ -801,7 +805,10 @@ void partitionFreeSlowPath(PartitionPage* page)
// non-full page list. Also make it the current page to increase the
// chances of it being filled up again. The old current page will be
// the next page.
- page->nextPage = bucket->activePagesHead;
+ if (UNLIKELY(bucket->activePagesHead == &PartitionRootGeneric::gSeedPage))
+ page->nextPage = 0;
+ else
+ page->nextPage = bucket->activePagesHead;
bucket->activePagesHead = page;
--bucket->numFullPages;
// Special case: for a partition page with just a single slot, it may
« no previous file with comments | « no previous file | Source/wtf/PartitionAllocTest.cpp » ('j') | Source/wtf/PartitionAllocTest.cpp » ('J')

Powered by Google App Engine
This is Rietveld 408576698