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

Side by Side Diff: base/trace_event/memory_dump_manager.cc

Issue 2881563002: memory-infra: Fix deadlock in MemoryDumpManager (Closed)
Patch Set: remove brackets Created 3 years, 7 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 unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "base/trace_event/memory_dump_manager.h" 5 #include "base/trace_event/memory_dump_manager.h"
6 6
7 #include <inttypes.h> 7 #include <inttypes.h>
8 #include <stdio.h> 8 #include <stdio.h>
9 9
10 #include <algorithm> 10 #include <algorithm>
(...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after
166 dumper_registrations_ignored_for_testing_(false), 166 dumper_registrations_ignored_for_testing_(false),
167 heap_profiling_enabled_(false) { 167 heap_profiling_enabled_(false) {
168 g_next_guid.GetNext(); // Make sure that first guid is not zero. 168 g_next_guid.GetNext(); // Make sure that first guid is not zero.
169 169
170 // At this point the command line may not be initialized but we try to 170 // At this point the command line may not be initialized but we try to
171 // enable the heap profiler to capture allocations as soon as possible. 171 // enable the heap profiler to capture allocations as soon as possible.
172 EnableHeapProfilingIfNeeded(); 172 EnableHeapProfilingIfNeeded();
173 } 173 }
174 174
175 MemoryDumpManager::~MemoryDumpManager() { 175 MemoryDumpManager::~MemoryDumpManager() {
176 Thread* dump_thread = nullptr;
177 {
178 AutoLock lock(lock_);
179 if (dump_thread_) {
180 dump_thread = dump_thread_.get();
181 }
182 }
183 if (dump_thread) {
184 dump_thread->Stop();
185 }
176 AutoLock lock(lock_); 186 AutoLock lock(lock_);
177 if (dump_thread_) { 187 dump_thread_.reset();
178 dump_thread_->Stop();
179 dump_thread_.reset();
180 }
181 } 188 }
182 189
183 void MemoryDumpManager::EnableHeapProfilingIfNeeded() { 190 void MemoryDumpManager::EnableHeapProfilingIfNeeded() {
184 if (heap_profiling_enabled_) 191 if (heap_profiling_enabled_)
185 return; 192 return;
186 193
187 if (!CommandLine::InitializedForCurrentProcess() || 194 if (!CommandLine::InitializedForCurrentProcess() ||
188 !CommandLine::ForCurrentProcess()->HasSwitch( 195 !CommandLine::ForCurrentProcess()->HasSwitch(
189 switches::kEnableHeapProfiling)) 196 switches::kEnableHeapProfiling))
190 return; 197 return;
(...skipping 689 matching lines...) Expand 10 before | Expand all | Expand 10 after
880 if (iter == process_dumps.end()) { 887 if (iter == process_dumps.end()) {
881 std::unique_ptr<ProcessMemoryDump> new_pmd( 888 std::unique_ptr<ProcessMemoryDump> new_pmd(
882 new ProcessMemoryDump(heap_profiler_serialization_state, dump_args)); 889 new ProcessMemoryDump(heap_profiler_serialization_state, dump_args));
883 iter = process_dumps.insert(std::make_pair(pid, std::move(new_pmd))).first; 890 iter = process_dumps.insert(std::make_pair(pid, std::move(new_pmd))).first;
884 } 891 }
885 return iter->second.get(); 892 return iter->second.get();
886 } 893 }
887 894
888 } // namespace trace_event 895 } // namespace trace_event
889 } // namespace base 896 } // namespace base
OLDNEW
« 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