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

Unified Diff: base/allocator/partition_allocator/partition_alloc_unittest.cc

Issue 2799323003: Fix PartitionAlloc cookies for large in-place reallocs (Closed)
Patch Set: Fix issue Created 3 years, 8 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 | « base/allocator/partition_allocator/partition_alloc.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: base/allocator/partition_allocator/partition_alloc_unittest.cc
diff --git a/base/allocator/partition_allocator/partition_alloc_unittest.cc b/base/allocator/partition_allocator/partition_alloc_unittest.cc
index 1ed26bba972de191589fb5fee45fbeebc599aaec..0507c0b4aa93469d8a5ea29ccc3d37f40b0a1f4c 100644
--- a/base/allocator/partition_allocator/partition_alloc_unittest.cc
+++ b/base/allocator/partition_allocator/partition_alloc_unittest.cc
@@ -2088,6 +2088,27 @@ TEST(PartitionAllocTest, PurgeDiscardable) {
}
}
+TEST(PartitionAllocTest, ReallocMovesCookies) {
+ TestSetup();
+
+ // Resize so as to be sure to hit a "resize in place" case, and ensure that
+ // use of the entire result is compatible with the debug mode's cookies, even
+ // when the bucket size is large enough to span more than one partition page
+ // and we can track the "raw" size. See https://crbug.com/709271
+ const size_t kSize = base::kMaxSystemPagesPerSlotSpan * base::kSystemPageSize;
+ void* ptr =
+ PartitionAllocGeneric(generic_allocator.root(), kSize + 1, type_name);
+ EXPECT_TRUE(ptr);
+
+ memset(ptr, 0xbd, kSize + 1);
+ ptr = PartitionReallocGeneric(generic_allocator.root(), ptr, kSize + 2,
+ type_name);
+ EXPECT_TRUE(ptr);
+
+ memset(ptr, 0xbd, kSize + 2);
+ PartitionFreeGeneric(generic_allocator.root(), ptr);
+}
+
} // namespace base
#endif // !defined(MEMORY_TOOL_REPLACES_ALLOCATOR)
« no previous file with comments | « base/allocator/partition_allocator/partition_alloc.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698