Bug 1039579 - CrashReporterParent::NotifyCrashService must always be on the main thread, r=ted
authorBenjamin Smedberg <benjamin@smedbergs.us>
Fri, 18 Jul 2014 13:31:21 -0400
changeset 216876 ea3f55623a896fe29ff7cc65973effdf3f494e69
parent 216875 9216dcba67804a322f2f79b27ff9f344ef7b0f5c
child 216877 fcb0e9c6c148eeb22093bcb33b37fd4664567d57
push id515
push userraliiev@mozilla.com
push dateMon, 06 Oct 2014 12:51:51 +0000
treeherdermozilla-release@267c7a481bef [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersted
bugs1039579
milestone33.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 1039579 - CrashReporterParent::NotifyCrashService must always be on the main thread, r=ted
dom/ipc/CrashReporterParent.cpp
--- a/dom/ipc/CrashReporterParent.cpp
+++ b/dom/ipc/CrashReporterParent.cpp
@@ -6,16 +6,18 @@
 #include "CrashReporterParent.h"
 #include "mozilla/dom/ContentParent.h"
 #include "nsXULAppAPI.h"
 #include <time.h>
 
 #ifdef MOZ_CRASHREPORTER
 #include "nsExceptionHandler.h"
 #include "nsICrashService.h"
+#include "mozilla/SyncRunnable.h"
+#include "nsThreadUtils.h"
 #endif
 
 using namespace base;
 
 namespace mozilla {
 namespace dom {
 
 void
@@ -109,16 +111,17 @@ CrashReporterParent::GenerateChildData(c
     MOZ_ASSERT(mInitialized);
 
     nsAutoCString type;
     switch (mProcessType) {
         case GeckoProcessType_Content:
             type = NS_LITERAL_CSTRING("content");
             break;
         case GeckoProcessType_Plugin:
+        case GeckoProcessType_GMPlugin:
             type = NS_LITERAL_CSTRING("plugin");
             break;
         default:
             NS_ERROR("unknown process type");
             break;
     }
     mNotes.Put(NS_LITERAL_CSTRING("ProcessType"), type);
 
@@ -130,24 +133,40 @@ CrashReporterParent::GenerateChildData(c
         mNotes.Put(NS_LITERAL_CSTRING("Notes"), mAppNotes);
 
     bool ret = CrashReporter::AppendExtraData(mChildDumpID, mNotes);
     if (ret && processNotes)
         ret = CrashReporter::AppendExtraData(mChildDumpID, *processNotes);
     if (!ret)
         NS_WARNING("problem appending child data to .extra");
 
-    NotifyCrashService();
+    nsCOMPtr<nsIThread> mainThread = do_GetMainThread();
+    class NotifyOnMainThread : public nsRunnable
+    {
+    public:
+        NotifyOnMainThread(CrashReporterParent* aCR)
+            : mCR(aCR)
+        { }
 
+        NS_IMETHOD Run() {
+            mCR->NotifyCrashService();
+            return NS_OK;
+        }
+    private:
+        CrashReporterParent* mCR;
+    };
+    SyncRunnable::DispatchToThread(mainThread, new NotifyOnMainThread(this));
     return ret;
 }
 
 void
 CrashReporterParent::NotifyCrashService()
 {
+    MOZ_ASSERT(NS_IsMainThread());
+
     nsCOMPtr<nsICrashService> crashService =
         do_GetService("@mozilla.org/crashservice;1");
     if (!crashService) {
         return;
     }
 
     if (mProcessType == GeckoProcessType_Content) {
         crashService->AddCrash(nsICrashService::PROCESS_TYPE_CONTENT,