Bug 1122322 - Fix crash in worker memory reporter. r=bent, a=sledru
authorNicholas Nethercote <nnethercote@mozilla.com>
Thu, 15 Jan 2015 20:12:20 -0800
changeset 240205 1b311ea5972239807714781b5ec7c2eac08b2abe
parent 240204 ac9e91778eb628ae359fbe87bda551769b83a679
child 240206 def96daddf8c7d067583cea6c439ab7866ac73cc
push id7494
push userryanvm@gmail.com
push dateTue, 20 Jan 2015 16:27:23 +0000
treeherdermozilla-aurora@1b311ea59722 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbent, sledru
bugs1122322
milestone37.0a2
Bug 1122322 - Fix crash in worker memory reporter. r=bent, a=sledru
dom/workers/WorkerPrivate.cpp
--- a/dom/workers/WorkerPrivate.cpp
+++ b/dom/workers/WorkerPrivate.cpp
@@ -2032,16 +2032,22 @@ public:
     // Assumes that WorkerJSRuntimeStats will hold a reference to |path|, and
     // not a copy, as TryToMapAddon() may later modify if.
     nsCString path;
     WorkerJSRuntimeStats rtStats(path);
 
     {
       MutexAutoLock lock(mMutex);
 
+      if (!mWorkerPrivate ||
+          !mWorkerPrivate->BlockAndCollectRuntimeStats(&rtStats, aAnonymize)) {
+        // Returning NS_OK here will effectively report 0 memory.
+        return NS_OK;
+      }
+
       path.AppendLiteral("explicit/workers/workers(");
       if (aAnonymize && !mWorkerPrivate->Domain().IsEmpty()) {
         path.AppendLiteral("<anonymized-domain>)/worker(<anonymized-url>");
       } else {
         nsCString escapedDomain(mWorkerPrivate->Domain());
         if (escapedDomain.IsEmpty()) {
           escapedDomain += "chrome";
         } else {
@@ -2051,22 +2057,16 @@ public:
         path.AppendLiteral(")/worker(");
         NS_ConvertUTF16toUTF8 escapedURL(mWorkerPrivate->ScriptURL());
         escapedURL.ReplaceChar('/', '\\');
         path.Append(escapedURL);
       }
       path.AppendPrintf(", 0x%p)/", static_cast<void*>(mWorkerPrivate));
 
       TryToMapAddon(path);
-
-      if (!mWorkerPrivate ||
-          !mWorkerPrivate->BlockAndCollectRuntimeStats(&rtStats, aAnonymize)) {
-        // Returning NS_OK here will effectively report 0 memory.
-        return NS_OK;
-      }
     }
 
     return xpc::ReportJSRuntimeExplicitTreeStats(rtStats, path,
                                                  aCallback, aClosure,
                                                  aAnonymize);
   }
 
 private: