Bug 1122322 - Fix crash in worker memory reporter. r=bent.
authorNicholas Nethercote <nnethercote@mozilla.com>
Thu, 15 Jan 2015 20:12:20 -0800
changeset 224466 c7ff0dd7ad8a42f81d366f0df3bb550b6616d755
parent 224465 5bf670f092eb9cbdae6103e2b78c60ec42f0fcf9
child 224467 7e6b191f83f739289756fae6590082be792a4a0e
push id28131
push usercbook@mozilla.com
push dateMon, 19 Jan 2015 15:10:25 +0000
treeherdermozilla-central@f8e4fdb89a05 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbent
bugs1122322
milestone38.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 1122322 - Fix crash in worker memory reporter. r=bent.
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: