Bug 1306317 - Fix BackgroundHangThread::ReportHang to handle empty mHangStack correctly. r=froydnj
authorJan de Mooij <jdemooij@mozilla.com>
Fri, 30 Sep 2016 14:46:19 +0200
changeset 316068 3852adf9af13d4731dfee2cb6daacb8004d8f2d7
parent 316067 02b1f8c28483f8dd5762580b762cf00e7529ee73
child 316069 abd0f2b6a2d474ea961307cbc5255e332de4c14c
push id30759
push userphilringnalda@gmail.com
push dateSat, 01 Oct 2016 06:25:09 +0000
treeherdermozilla-central@fcc62bbf09ee [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersfroydnj
bugs1306317
milestone52.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 1306317 - Fix BackgroundHangThread::ReportHang to handle empty mHangStack correctly. r=froydnj
xpcom/threads/BackgroundHangMonitor.cpp
--- a/xpcom/threads/BackgroundHangMonitor.cpp
+++ b/xpcom/threads/BackgroundHangMonitor.cpp
@@ -395,19 +395,22 @@ BackgroundHangThread::~BackgroundHangThr
 
 Telemetry::HangHistogram&
 BackgroundHangThread::ReportHang(PRIntervalTime aHangTime)
 {
   // Recovered from a hang; called on the monitor thread
   // mManager->mLock IS locked
 
   // Remove unwanted "js::RunScript" frame from the stack
-  for (const char** f = &mHangStack.back(); f >= mHangStack.begin(); f--) {
+  for (size_t i = 0; i < mHangStack.length(); ) {
+    const char** f = mHangStack.begin() + i;
     if (!mHangStack.IsInBuffer(*f) && !strcmp(*f, "js::RunScript")) {
       mHangStack.erase(f);
+    } else {
+      i++;
     }
   }
 
   // Collapse duplicated "(chrome script)" and "(content script)" entries in the stack.
   auto it = std::unique(mHangStack.begin(), mHangStack.end(), StackScriptEntriesCollapser);
   mHangStack.erase(it, mHangStack.end());
 
   // Limit the depth of the reported stack if greater than our limit. Only keep its