Commit f75937ca authored by Andreas Haas's avatar Andreas Haas Committed by Commit Bot

[partitionalloc] Change OOM_CRASH macro for easier crash classification

Crashes caused by the OOM_CRASH macro are currently not classified as
OOM crashes by Chrome Crash at the moment. The reason is that Chrome
Crash analyzes the stack trace to do the classification, and OOM_CRASH
does not show up in the stack trace at the moment.

This CL changes OOM_CRASH to call the NOINLINE function OnNoMemory,
which then causes the crash. Thereby the OOM crash is visible on the
stack trace and can thus be classified correctly by Chrome Crash.

R=rmargold@chromium.org, yuzus@chromium.org

Bug: chromium:1019661
Change-Id: Id1a755076db4464b5de9a36aaf4ddeaa9a7dbc16
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1906148
Commit-Queue: Andreas Haas <ahaas@chromium.org>
Reviewed-by: default avatarYuzu Saijo <yuzus@chromium.org>
Reviewed-by: default avatarKentaro Hara <haraken@chromium.org>
Cr-Commit-Position: refs/heads/master@{#714448}
parent a0829135
......@@ -7,34 +7,33 @@
#include "base/allocator/partition_allocator/oom_callback.h"
#include "base/logging.h"
#include "base/process/memory.h"
#include "build/build_config.h"
#if defined(OS_WIN)
#include <windows.h>
#endif
// Do not want trivial entry points just calling OOM_CRASH() to be
// commoned up by linker icf/comdat folding.
#define OOM_CRASH_PREVENT_ICF() \
volatile int oom_crash_inhibit_icf = __LINE__; \
ALLOW_UNUSED_LOCAL(oom_crash_inhibit_icf)
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.
NOINLINE void OnNoMemory() {
base::internal::RunPartitionAllocOomCallback();
#if defined(OS_WIN)
::RaiseException(base::win::kOomExceptionCode, EXCEPTION_NONCONTINUABLE, 0,
nullptr);
#endif
IMMEDIATE_CRASH();
}
} // namespace
// OOM_CRASH() - Specialization of IMMEDIATE_CRASH which will raise a custom
// exception on Windows to signal this is OOM and not a normal assert.
#if defined(OS_WIN)
#define OOM_CRASH() \
do { \
OOM_CRASH_PREVENT_ICF(); \
base::internal::RunPartitionAllocOomCallback(); \
::RaiseException(0xE0000008, EXCEPTION_NONCONTINUABLE, 0, nullptr); \
IMMEDIATE_CRASH(); \
// OOM_CRASH() is called by users of PageAllocator (including PartitionAlloc) to
// signify an allocation failure from the platform.
#define OOM_CRASH() \
do { \
OnNoMemory(); \
} while (0)
#else
#define OOM_CRASH() \
do { \
base::internal::RunPartitionAllocOomCallback(); \
OOM_CRASH_PREVENT_ICF(); \
IMMEDIATE_CRASH(); \
} while (0)
#endif
#endif // BASE_ALLOCATOR_PARTITION_ALLOCATOR_OOM_H_
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