Add task backtrace to crash stack trace logging
This CL enables the task backtrace stored in PendingTasks to be surfaced
in crash stack output.
Note 1: This does not yet trace across Mojo calls, they are all rooted at
mojo::SimpleWatcher::Context::Notify() and have no prior context as to
what task called into Mojo.
Note 2: The traces are of PostTask() callers rather than the tasks
themselves.
Example stack with task trace:
[227789:227789:0315/151703.372889:FATAL:app_banner_manager.cc(358)] Check failed: 0.
#0 0x7fa0156cfb39 base::debug::CollectStackTrace()
#1 0x7fa0155d4443 base::debug::StackTrace::StackTrace()
#2 0x7fa0155f3420 logging::LogMessage::~LogMessage()
#3 0x5566aee301ef banners::AppBannerManager::OnDidPerformInstallableCheck()
#4 0x5566ae7e24ac base::internal::Invoker<>::Run()
#5 0x5566aeebf273 InstallableManager::RunCallback()
#6 0x5566aeebe6a4 InstallableManager::WorkOnTask()
#7 0x5566ae72e89c base::internal::Invoker<>::Run()
#8 0x7fa0127c35f1 base::internal::FunctorTraits<>::Invoke<>()
#9 0x7fa01564fbd8 base::TaskAnnotator::RunTask()
...
#27 0x5566ae5f91b3 ChromeMain
#28 0x7fa00661b2b1 __libc_start_main
#29 0x5566ae5f902a _start
Task trace:
#0 0x7fa012d2ea47 content::ServiceWorkerContextWrapper::DidCheckHasServiceWorker()
#1 0x7fa012da14df content::ServiceWorkerStorage::FindForDocumentInDB()
#2 0x7fa012da0787 content::ServiceWorkerStorage::FindRegistrationForDocument()
#3 0x7fa012d2e787 content::ServiceWorkerContextWrapper::CheckHasServiceWorker()
#4 0x7fa012b6d88f content::ManifestIconDownloader::ScaleIcon()
Task trace buffer limit hit, update PendingTask::kTaskBacktraceLength to increase.
Bug: 942401
Change-Id: I6efbfaea32b4a3c08225898c6da7b53c39ffb904
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1525249
Commit-Queue: Alan Cutter <[email protected]>
Reviewed-by: Albert J. Wong <[email protected]>
Cr-Commit-Position: refs/heads/master@{#642816}
diff --git a/base/pending_task.h b/base/pending_task.h
index f736421..a609a910 100644
--- a/base/pending_task.h
+++ b/base/pending_task.h
@@ -54,9 +54,10 @@
// if the task hasn't been inserted in a sequence yet.
TimeTicks queue_time;
- // Chain of up-to-four symbols of the parent tasks which led to this one being
- // posted.
- std::array<const void*, 4> task_backtrace = {};
+ // Chain of symbols of the parent tasks which led to this one being posted.
+ static constexpr size_t kTaskBacktraceLength = 4;
+ std::array<const void*, kTaskBacktraceLength> task_backtrace = {};
+ bool task_backtrace_overflow = false;
// Secondary sort key for run time.
int sequence_num = 0;