Bug 1090921 - Logging to see which tasks remain alive too long (r=dvander)
authorBill McCloskey <billm@mozilla.com>
Thu, 12 Mar 2015 17:06:06 -0700
changeset 233563 5c8eccfa028dab4a080f352809ae58f89f8bf826
parent 233562 56da5d401fe2b13af17c353350ea3729d8018419
child 233564 7d9a91ee3d484f651b31e3a2a4724e33836890aa
push id28417
push userryanvm@gmail.com
push dateFri, 13 Mar 2015 19:52:44 +0000
treeherdermozilla-central@977add19414a [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersdvander
bugs1090921
milestone39.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1090921 - Logging to see which tasks remain alive too long (r=dvander)
ipc/chromium/src/base/message_loop.cc
ipc/chromium/src/base/tracked.cc
ipc/chromium/src/base/tracked.h
--- a/ipc/chromium/src/base/message_loop.cc
+++ b/ipc/chromium/src/base/message_loop.cc
@@ -402,16 +402,25 @@ void MessageLoop::ReloadWorkQueue() {
     if (incoming_queue_.empty())
       return;
     std::swap(incoming_queue_, work_queue_);
     DCHECK(incoming_queue_.empty());
   }
 }
 
 bool MessageLoop::DeletePendingTasks() {
+#ifdef DEBUG
+  if (!work_queue_.empty()) {
+    Task* task = work_queue_.front().task;
+    tracked_objects::Location loc = task->GetBirthPlace();
+    printf("Unexpected task! %s:%s:%d\n",
+	   loc.function_name(), loc.file_name(), loc.line_number());
+  }
+#endif
+
   MOZ_ASSERT(work_queue_.empty());
   bool did_work = !deferred_non_nestable_work_queue_.empty();
   while (!deferred_non_nestable_work_queue_.empty()) {
     Task* task = deferred_non_nestable_work_queue_.front().task;
     deferred_non_nestable_work_queue_.pop();
     delete task;
   }
   did_work |= !delayed_work_queue_.empty();
--- a/ipc/chromium/src/base/tracked.cc
+++ b/ipc/chromium/src/base/tracked.cc
@@ -76,16 +76,23 @@ void Tracked::SetBirthPlace(const Locati
     tracked_births_->ForgetBirth();
   ThreadData* current_thread_data = ThreadData::current();
   if (!current_thread_data)
     return;  // Shutdown started, and this thread wasn't registered.
   tracked_births_ = current_thread_data->FindLifetime(from_here);
   tracked_births_->RecordBirth();
 }
 
+Location Tracked::GetBirthPlace() const {
+  if (tracked_births_) {
+    return tracked_births_->location();
+  }
+  return Location();
+}
+
 void Tracked::ResetBirthTime() {
   tracked_birth_time_ = Time::Now();
 }
 
 bool Tracked::MissingBirthplace() const {
   return -1 == tracked_births_->location().line_number();
 }
 
--- a/ipc/chromium/src/base/tracked.h
+++ b/ipc/chromium/src/base/tracked.h
@@ -94,16 +94,17 @@ class Births;
 
 class Tracked {
  public:
   Tracked();
   virtual ~Tracked();
 
   // Used to record the FROM_HERE location of a caller.
   void SetBirthPlace(const Location& from_here);
+  Location GetBirthPlace() const;
 
   // When a task sits around a long time, such as in a timer, or object watcher,
   // this method should be called when the task becomes active, and its
   // significant lifetime begins (and its waiting to be woken up has passed).
   void ResetBirthTime();
 
   bool MissingBirthplace() const;