Commit bf708dee authored by Bruce Dawson's avatar Bruce Dawson Committed by Chromium LUCI CQ

Preserve OOM call stack entries

Partition Alloc has a few different out-of-memory error reporting paths
with different meanings for the "size" parameter. These different paths
are supposed to be distinguishable by looking at the call stack but a
combination of code folding and tail-call optimizations means that this
is not actually guaranteed. In one (most?) crash dumps a call to
PartitionOutOfMemoryWithLargeVirtualSize shows up on the stack as a call
to PartitionExcessiveAllocationSize.

This change disables code folding for the relevant functions, and
disables tail calls as well.

This should make understanding OOM failures easier.

Bug: 1159694
Change-Id: I0faf577fa0e82e88f7a06940c97a570e778e5ec8
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2607585
Commit-Queue: Bruce Dawson <brucedawson@chromium.org>
Commit-Queue: Will Harris <wfh@chromium.org>
Reviewed-by: default avatarWill Harris <wfh@chromium.org>
Reviewed-by: default avatarAnton Bikineev <bikineev@chromium.org>
Auto-Submit: Bruce Dawson <brucedawson@chromium.org>
Cr-Commit-Position: refs/heads/master@{#840248}
parent 4ce33da6
......@@ -6,6 +6,7 @@
#define BASE_ALLOCATOR_PARTITION_ALLOCATOR_OOM_H_
#include "base/allocator/partition_allocator/oom_callback.h"
#include "base/compiler_specific.h"
#include "base/process/memory.h"
#include "build/build_config.h"
......@@ -15,8 +16,9 @@
namespace {
// The crash is generated in a NOINLINE function so that we can classify the
// crash as an OOM solely by analyzing the stack trace.
[[noreturn]] NOINLINE void OnNoMemory(size_t size) {
// crash as an OOM solely by analyzing the stack trace. It is tagged as
// NOT_TAIL_CALLED to ensure that its parent function stays on the stack.
[[noreturn]] NOINLINE void NOT_TAIL_CALLED OnNoMemory(size_t size) {
base::internal::RunPartitionAllocOomCallback();
base::internal::OnNoMemoryInternal(size);
IMMEDIATE_CRASH();
......
......@@ -5,6 +5,8 @@
#include "base/allocator/partition_allocator/partition_oom.h"
#include "base/allocator/partition_allocator/oom.h"
#include "base/compiler_specific.h"
#include "base/debug/alias.h"
#include "build/build_config.h"
namespace base {
......@@ -12,17 +14,27 @@ namespace internal {
OomFunction g_oom_handling_function = nullptr;
void NOINLINE PartitionExcessiveAllocationSize(size_t size) {
NOINLINE void NOT_TAIL_CALLED PartitionExcessiveAllocationSize(size_t size) {
// Prevent code folding.
const int line_number = __LINE__;
base::debug::Alias(&line_number);
OOM_CRASH(size);
}
#if !defined(ARCH_CPU_64_BITS)
NOINLINE void PartitionOutOfMemoryWithLotsOfUncommitedPages(size_t size) {
NOINLINE void NOT_TAIL_CALLED
PartitionOutOfMemoryWithLotsOfUncommitedPages(size_t size) {
// Prevent code folding.
const int line_number = __LINE__;
base::debug::Alias(&line_number);
OOM_CRASH(size);
}
[[noreturn]] NOINLINE void PartitionOutOfMemoryWithLargeVirtualSize(
size_t virtual_size) {
[[noreturn]] NOINLINE void NOT_TAIL_CALLED
PartitionOutOfMemoryWithLargeVirtualSize(size_t virtual_size) {
// Prevent code folding.
const int line_number = __LINE__;
base::debug::Alias(&line_number);
OOM_CRASH(virtual_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