Commit 46433ade authored by Ulan Degenbaev's avatar Ulan Degenbaev Committed by Commit Bot

Harden V8IsolateMemoryDumpProvider::DumpHeapStatistics.

Currently the function adds "other_spaces" that contains the difference
between the total metrics and the sum of spaces.

If the sizes do not match, then this can result in size_t underflow:
https://bugs.chromium.org/p/v8/issues/detail?id=7668

We should just assert that the sizes match and remove "other_spaces".

Bug: v8:7668
Change-Id: Ib768cec6b2fb7faf3e2c53a89cbd926547ddf603
Reviewed-on: https://chromium-review.googlesource.com/1016602
Commit-Queue: Ulan Degenbaev <ulan@chromium.org>
Reviewed-by: default avatarJochen Eisinger <jochen@chromium.org>
Reviewed-by: default avatarSiddhartha S <ssid@chromium.org>
Cr-Commit-Position: refs/heads/master@{#553519}
parent 032c2ca4
......@@ -255,7 +255,6 @@ const char* const kAllocatorDumpNameWhitelist[] = {
"v8/isolate_0x?/heap_spaces/map_space",
"v8/isolate_0x?/heap_spaces/new_space",
"v8/isolate_0x?/heap_spaces/old_space",
"v8/isolate_0x?/heap_spaces/other_spaces",
"v8/isolate_0x?/heap_spaces/read_only_space",
"v8/isolate_0x?/malloc",
"v8/isolate_0x?/zapped_for_debug",
......
......@@ -158,24 +158,10 @@ void V8IsolateMemoryDumpProvider::DumpHeapStatistics(
space_used_size);
}
// Compute the rest of the memory, not accounted by the spaces above.
std::string other_spaces_name = space_name_prefix + "/other_spaces";
auto* other_dump =
process_memory_dump->CreateAllocatorDump(other_spaces_name);
other_dump->AddScalar(
base::trace_event::MemoryAllocatorDump::kNameSize,
base::trace_event::MemoryAllocatorDump::kUnitsBytes,
heap_statistics.total_physical_size() - known_spaces_physical_size);
other_dump->AddScalar(
"allocated_objects_size",
base::trace_event::MemoryAllocatorDump::kUnitsBytes,
heap_statistics.used_heap_size() - known_spaces_used_size);
other_dump->AddScalar("virtual_size",
base::trace_event::MemoryAllocatorDump::kUnitsBytes,
heap_statistics.total_heap_size() - known_spaces_size);
// Sanity checks.
DCHECK_EQ(heap_statistics.total_physical_size(), known_spaces_physical_size);
DCHECK_EQ(heap_statistics.used_heap_size(), known_spaces_used_size);
DCHECK_EQ(heap_statistics.total_heap_size(), known_spaces_size);
// If V8 zaps garbage, all the memory mapped regions become resident,
// so we add an extra dump to avoid mismatches w.r.t. the total
......
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