Bug 840277 - Explicitly check that the preallocated process hasn't been killed before we use it. r=cjones
authorJustin Lebar <justin.lebar@gmail.com>
Thu, 14 Feb 2013 15:41:29 -0500
changeset 131835 d1738e1adece807fc5d2b91f8ce97a19fa8bb40e
parent 131834 df71fc49f14fee5fee76502822ca399a139f5eb0
child 131836 d87c3a49bff187ffbe5f1784546136f9dc2b153f
push id2323
push userbbajaj@mozilla.com
push dateMon, 01 Apr 2013 19:47:02 +0000
treeherdermozilla-beta@7712be144d91 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerscjones
bugs840277
milestone21.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 840277 - Explicitly check that the preallocated process hasn't been killed before we use it. r=cjones We have to do this check /after/ we set the process's priority, since before then, it has BACKGROUND priority and is a candidate for killing.
dom/ipc/ContentParent.cpp
--- a/dom/ipc/ContentParent.cpp
+++ b/dom/ipc/ContentParent.cpp
@@ -559,17 +559,32 @@ ContentParent::TransformPreallocatedInto
     // TemporarilySetProcessPriorityToForeground() from within
     // ContentChild::AllocPBrowser, but this happens earlier, thus reducing the
     // window in which the child might be killed due to low memory.
     if (Preferences::GetBool("dom.ipc.processPriorityManager.enabled")) {
         SetProcessPriority(base::GetProcId(mSubprocess->GetChildProcessHandle()),
                            PROCESS_PRIORITY_FOREGROUND);
     }
 
-    // If this fails, the child process died.
+    // Now that we've increased the process's priority from BACKGROUND (where
+    // the preallocated app sits) to something higher, check whether the process
+    // is still alive.  Hopefully the process won't unexpectedly crash after
+    // this point!
+    //
+    // It's not legal to call DidProcessCrash on Windows if the process has not
+    // terminated yet, so we have to skip this check there.
+
+#ifndef XP_WIN
+    bool exited = false;
+    base::DidProcessCrash(&exited, mSubprocess->GetChildProcessHandle());
+    if (exited) {
+        return false;
+    }
+#endif
+
     return SendSetProcessPrivileges(aPrivs);
 }
 
 void
 ContentParent::ShutDownProcess()
 {
   if (!mIsDestroyed) {
     const InfallibleTArray<PIndexedDBParent*>& idbParents =