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 419801 3852adf9af13d4731dfee2cb6daacb8004d8f2d7
parent 419800 02b1f8c28483f8dd5762580b762cf00e7529ee73
child 419802 abd0f2b6a2d474ea961307cbc5255e332de4c14c
push id31023
push usercykesiopka.bmo@gmail.com
push dateSat, 01 Oct 2016 01:30:33 +0000
reviewersfroydnj
bugs1306317
milestone52.0a1
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