Index: base/trace_event/memory_dump_manager.cc |
diff --git a/base/trace_event/memory_dump_manager.cc b/base/trace_event/memory_dump_manager.cc |
index 8d307cef5cbe7c0dc5eafad2bddf6f9ea08e0687..32c93f7558e2900ebbaf0c87efe19c3b9e824a20 100644 |
--- a/base/trace_event/memory_dump_manager.cc |
+++ b/base/trace_event/memory_dump_manager.cc |
@@ -173,11 +173,18 @@ MemoryDumpManager::MemoryDumpManager() |
} |
MemoryDumpManager::~MemoryDumpManager() { |
- AutoLock lock(lock_); |
- if (dump_thread_) { |
- dump_thread_->Stop(); |
- dump_thread_.reset(); |
+ Thread* dump_thread = nullptr; |
+ { |
+ AutoLock lock(lock_); |
+ if (dump_thread_) { |
+ dump_thread = dump_thread_.get(); |
+ } |
+ } |
+ if (dump_thread) { |
+ dump_thread->Stop(); |
} |
+ AutoLock lock(lock_); |
+ dump_thread_.reset(); |
} |
void MemoryDumpManager::EnableHeapProfilingIfNeeded() { |