Commit d9ad7246 authored by Hajime Hoshi's avatar Hajime Hoshi Committed by Commit Bot

Bug fix: SharedMemory's mapped IDs can be empty on OnMemoryDump

On OnMemoryDump, base::SharedMemory's IDs are used to create ownership
edges. However, there is no guarantee that the ID is still valid when
OnMemoryDump is called. Actually, some crashes [1] are found when
MemoryAllocatorDumpGuid::UseSharedMemoryBasedGUIDs() is true [2].

This CL fixes this bug to avoid dumping when shared memory id is
invalid (empty). Also, this CL changes OnMemoryDump use SharedMemory::
mapped_id(), that returns an valid ID only when the shared memory is
actually mapped, so that we can avoid unnecessary dumps.

[1] https://build.chromium.org/p/tryserver.chromium.linux/builders/linux_chromium_rel_ng/builds/501311
[2] This is now always false, but we plan to make this return true to
    use new ownership edges.

Bug: 604726
Change-Id: I2400ba334860e57b9b83a785cd69f4a32b8ef151
Reviewed-on: https://chromium-review.googlesource.com/571386Reviewed-by: default avatarPrimiano Tucci <primiano@chromium.org>
Reviewed-by: default avatarSiddhartha S <ssid@chromium.org>
Reviewed-by: default avatarJohn Bauman <jbauman@chromium.org>
Commit-Queue: Hajime Hoshi <hajimehoshi@chromium.org>
Cr-Commit-Position: refs/heads/master@{#488134}
parent 67aea3fa
......@@ -144,9 +144,11 @@ bool ServerSharedBitmapManager::OnMemoryDump(
auto guid = GetSharedBitmapGUIDForTracing(bitmap.first);
base::UnguessableToken shared_memory_guid;
if (bitmap.second->memory) {
shared_memory_guid = bitmap.second->memory->handle().GetGUID();
pmd->CreateSharedMemoryOwnershipEdge(
dump->guid(), guid, shared_memory_guid, 0 /* importance*/);
shared_memory_guid = bitmap.second->memory->mapped_id();
if (!shared_memory_guid.is_empty()) {
pmd->CreateSharedMemoryOwnershipEdge(
dump->guid(), guid, shared_memory_guid, 0 /* importance*/);
}
} else {
pmd->CreateSharedGlobalAllocatorDump(guid);
pmd->AddOwnershipEdge(dump->guid(), guid);
......
......@@ -89,9 +89,11 @@ void GLImageSharedMemory::OnMemoryDump(
auto guid =
gfx::GetSharedMemoryGUIDForTracing(process_tracing_id, shared_memory_id_);
auto shared_memory_guid = shared_memory_->handle().GetGUID();
pmd->CreateSharedMemoryOwnershipEdge(dump->guid(), guid, shared_memory_guid,
0 /* importance */);
auto shared_memory_guid = shared_memory_->mapped_id();
if (!shared_memory_guid.is_empty()) {
pmd->CreateSharedMemoryOwnershipEdge(dump->guid(), guid, shared_memory_guid,
0 /* importance */);
}
}
} // namespace gl
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