Skip to content

Commit

Permalink
[discardable_memory] Call DumpWithoutCrashing when browser side fails.
Browse files Browse the repository at this point in the history
This CL adds 2 calls of `DumpWithoutCrashing` to help debug failures on
the browser side to allocate more discardable memory.

Bug: 1270558
Change-Id: I3b453808beb2f9c8d46d14e0cca3776aeaa7b223
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3297472
Commit-Queue: Thiabaud Engelbrecht <thiabaud@google.com>
Reviewed-by: Alex Gough <ajgo@chromium.org>
Reviewed-by: Benoit L <lizeb@chromium.org>
Cr-Commit-Position: refs/heads/main@{#945002}
  • Loading branch information
Thiabaud Engelbrecht authored and Chromium LUCI CQ committed Nov 24, 2021
1 parent 9e54562 commit e1f2900
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions base/memory/discardable_shared_memory.cc
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
#include "base/allocator/partition_allocator/page_allocator.h"
#include "base/atomicops.h"
#include "base/bits.h"
#include "base/debug/dump_without_crashing.h"
#include "base/feature_list.h"
#include "base/logging.h"
#include "base/memory/discardable_memory.h"
Expand Down Expand Up @@ -160,12 +161,20 @@ bool DiscardableSharedMemory::CreateAndMap(size_t size) {
shared_memory_region_ =
UnsafeSharedMemoryRegion::Create(checked_size.ValueOrDie());

if (!shared_memory_region_.IsValid())
// Failure in |CreateAndMap| will likely cause another process to crash, but
// not this one. We dump here and below to make it easier to investigate
// these crashes.
// TODO(crbug.com/1270558): Remove these calls when this bug is resolved.
if (!shared_memory_region_.IsValid()) {
base::debug::DumpWithoutCrashing();
return false;
}

shared_memory_mapping_ = shared_memory_region_.Map();
if (!shared_memory_mapping_.IsValid())
if (!shared_memory_mapping_.IsValid()) {
base::debug::DumpWithoutCrashing();
return false;
}

mapped_size_ = shared_memory_mapping_.mapped_size() -
AlignToPageSize(sizeof(SharedState));
Expand Down

0 comments on commit e1f2900

Please sign in to comment.