Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(244)

Unified Diff: base/trace_event/malloc_dump_provider.cc

Issue 2242953002: winheap_dump: handle errors gracefully (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: switch params to check, and match signedness Created 4 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: base/trace_event/malloc_dump_provider.cc
diff --git a/base/trace_event/malloc_dump_provider.cc b/base/trace_event/malloc_dump_provider.cc
index 26eb92319a23458cf2720248c5eafabb161bace5..7d0cb579315d4884e00327fa5175b01c5a3824bd 100644
--- a/base/trace_event/malloc_dump_provider.cc
+++ b/base/trace_event/malloc_dump_provider.cc
@@ -105,7 +105,18 @@ struct WinHeapInfo {
bool GetHeapInformation(WinHeapInfo* heap_info,
const std::set<void*>& block_to_skip) {
- CHECK(::HeapLock(heap_info->heap_id) == TRUE);
+ // NOTE: crbug.com/464430
+ // As a part of the Client/Server Runtine Subsystem (CSRSS) lockdown in the
+ // referenced bug, it will invalidate the heap used by CSRSS. The author has
+ // not found a way to clean up an invalid heap handle, so it will be left in
+ // the process's heap list. Therefore we need to support when there is this
+ // invalid heap handle in the heap list.
+ // HeapLock implicitly checks certain aspects of the HEAP structure, such as
+ // the signature. If this passes, we assume that this heap is valid and is
+ // not the one owned by CSRSS.
+ if (!::HeapLock(heap_info->heap_id)) {
+ return false;
+ }
PROCESS_HEAP_ENTRY heap_entry;
heap_entry.lpData = nullptr;
// Walk over all the entries in this heap.
@@ -161,15 +172,21 @@ void WinHeapMemoryDumpImpl(WinHeapInfo* all_heap_info) {
block_to_skip.insert(all_heaps.get());
// Retrieves some metrics about each heap.
+ size_t heap_info_errors = 0;
for (size_t i = 0; i < number_of_heaps; ++i) {
WinHeapInfo heap_info = {0};
heap_info.heap_id = all_heaps[i];
- GetHeapInformation(&heap_info, block_to_skip);
-
- all_heap_info->allocated_size += heap_info.allocated_size;
- all_heap_info->committed_size += heap_info.committed_size;
- all_heap_info->uncommitted_size += heap_info.uncommitted_size;
- all_heap_info->block_count += heap_info.block_count;
+ if (GetHeapInformation(&heap_info, block_to_skip)) {
+ all_heap_info->allocated_size += heap_info.allocated_size;
+ all_heap_info->committed_size += heap_info.committed_size;
+ all_heap_info->uncommitted_size += heap_info.uncommitted_size;
+ all_heap_info->block_count += heap_info.block_count;
+ } else {
+ ++heap_info_errors;
+ // See notes in GetHeapInformation() but we only expect 1 heap to not be
+ // able to be read.
+ CHECK_EQ(1u, heap_info_errors);
+ }
}
}
#endif // defined(OS_WIN)
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698