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

Unified Diff: base/trace_event/memory_dump_manager_unittest.cc

Issue 1620783002: tracing: fix edge case when dumping while trace being disabled (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fix Created 4 years, 11 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 | « base/trace_event/memory_dump_manager.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: base/trace_event/memory_dump_manager_unittest.cc
diff --git a/base/trace_event/memory_dump_manager_unittest.cc b/base/trace_event/memory_dump_manager_unittest.cc
index 03b3afa32e5201f3239a2c41e3d0fca8414fd1ed..c0ee57de96f49bc7c4e419917aadac51fb0eda9f 100644
--- a/base/trace_event/memory_dump_manager_unittest.cc
+++ b/base/trace_event/memory_dump_manager_unittest.cc
@@ -90,6 +90,9 @@ class MemoryDumpManagerDelegateForTesting : public MemoryDumpManagerDelegate {
NOTREACHED();
return MemoryDumpManager::kInvalidTracingProcessId;
}
+
+ // Promote the CreateProcessDump to public so it can be used by test fixtures.
+ using MemoryDumpManagerDelegate::CreateProcessDump;
};
class MockMemoryDumpProvider : public MemoryDumpProvider {
@@ -826,9 +829,30 @@ TEST_F(MemoryDumpManagerTest, DisableTracingWhileDumping) {
tracing_disabled_event.Signal();
run_loop.Run();
- // RequestGlobalMemoryDump() should still suceed even if some threads were
- // torn down during the dump.
- EXPECT_TRUE(last_callback_success_);
+ EXPECT_FALSE(last_callback_success_);
+}
+
+// Tests against race conditions that can happen if tracing is disabled before
+// the CreateProcessDump() call. Real-world regression: crbug.com/580295 .
+TEST_F(MemoryDumpManagerTest, DisableTracingRightBeforeStartOfDump) {
+ base::WaitableEvent tracing_disabled_event(false, false);
+ InitializeMemoryDumpManager(false /* is_coordinator */);
+
+ MockMemoryDumpProvider mdp;
+ RegisterDumpProvider(&mdp);
+ EnableTracingWithLegacyCategories(MemoryDumpManager::kTraceCategory);
+
+ EXPECT_CALL(*delegate_, RequestGlobalMemoryDump(_, _))
+ .WillOnce(Invoke([this](const MemoryDumpRequestArgs& args,
+ const MemoryDumpCallback& callback) {
+ DisableTracing();
+ delegate_->CreateProcessDump(args, callback);
+ }));
+
+ last_callback_success_ = true;
+ RequestGlobalDumpAndWait(MemoryDumpType::EXPLICITLY_TRIGGERED,
+ MemoryDumpLevelOfDetail::DETAILED);
+ EXPECT_FALSE(last_callback_success_);
}
TEST_F(MemoryDumpManagerTest, DumpOnBehalfOfOtherProcess) {
« no previous file with comments | « base/trace_event/memory_dump_manager.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698