Commit 160bf610 authored by Takashi Sakamoto's avatar Takashi Sakamoto Committed by Commit Bot

Make AlignedAllocFlags to invoke PartitionExcessiveAllocationSize when overflow is detected.

This CL fixes the following 2 tests' failures:
- OutOfMemoryDeathTest.AlignedAlloc
- OutOfMemoryDeathTest.AlignedRealloc

Bug: 998048
Change-Id: I83f5ac00aded8d750ab610db3c17c17fad8b7074
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2418631Reviewed-by: default avatarBartek Nowierski <bartekn@chromium.org>
Reviewed-by: default avatarKentaro Hara <haraken@chromium.org>
Reviewed-by: default avatarBenoit L <lizeb@chromium.org>
Reviewed-by: default avatarYuki Shiino <yukishiino@chromium.org>
Commit-Queue: Takashi Sakamoto <tasak@google.com>
Cr-Commit-Position: refs/heads/master@{#811123}
parent 01bffc5a
...@@ -67,6 +67,7 @@ ...@@ -67,6 +67,7 @@
#include "base/allocator/partition_allocator/partition_cookie.h" #include "base/allocator/partition_allocator/partition_cookie.h"
#include "base/allocator/partition_allocator/partition_direct_map_extent.h" #include "base/allocator/partition_allocator/partition_direct_map_extent.h"
#include "base/allocator/partition_allocator/partition_lock.h" #include "base/allocator/partition_allocator/partition_lock.h"
#include "base/allocator/partition_allocator/partition_oom.h"
#include "base/allocator/partition_allocator/partition_page.h" #include "base/allocator/partition_allocator/partition_page.h"
#include "base/allocator/partition_allocator/partition_ref_count.h" #include "base/allocator/partition_allocator/partition_ref_count.h"
#include "base/allocator/partition_allocator/partition_tag.h" #include "base/allocator/partition_allocator/partition_tag.h"
...@@ -1110,6 +1111,16 @@ ALWAYS_INLINE void* PartitionRoot<thread_safe>::AlignedAllocFlags( ...@@ -1110,6 +1111,16 @@ ALWAYS_INLINE void* PartitionRoot<thread_safe>::AlignedAllocFlags(
<< (sizeof(size_t) * 8 - base::bits::CountLeadingZeroBits(size - 1)); << (sizeof(size_t) * 8 - base::bits::CountLeadingZeroBits(size - 1));
} }
#if BUILDFLAG(USE_PARTITION_ALLOC_AS_MALLOC)
if (requested_size > MaxDirectMapped()) {
if (flags & PartitionAllocReturnNull)
return nullptr;
// OutOfMemoryDeathTest.AlignedAlloc requires base::OnNoMemoryInternal
// (invoked by PartitionExcessiveAllocationSize).
internal::PartitionExcessiveAllocationSize(size);
IMMEDIATE_CRASH(); // Not required, kept as documentation.
}
#endif
PA_CHECK(requested_size >= size); // Overflow check. PA_CHECK(requested_size >= size); // Overflow check.
bool no_hooks = flags & PartitionAllocNoHooks; bool no_hooks = flags & PartitionAllocNoHooks;
void* ptr = no_hooks ? AllocFlagsNoHooks(0, requested_size) void* ptr = no_hooks ? AllocFlagsNoHooks(0, requested_size)
......
...@@ -10,13 +10,14 @@ ...@@ -10,13 +10,14 @@
#include <stddef.h> #include <stddef.h>
#include "base/base_export.h"
#include "base/compiler_specific.h" #include "base/compiler_specific.h"
#include "build/build_config.h" #include "build/build_config.h"
namespace base { namespace base {
namespace internal { namespace internal {
NOINLINE void PartitionExcessiveAllocationSize(size_t size); BASE_EXPORT NOINLINE void PartitionExcessiveAllocationSize(size_t size);
#if !defined(ARCH_CPU_64_BITS) #if !defined(ARCH_CPU_64_BITS)
NOINLINE void PartitionOutOfMemoryWithLotsOfUncommitedPages(size_t size); NOINLINE void PartitionOutOfMemoryWithLotsOfUncommitedPages(size_t size);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment