Bug 840277 - Explicitly check that the preallocated process hasn't been killed before we use it. r=cjones
☠☠ backed out by c2752716d6c8 ☠ ☠
authorJustin Lebar <justin.lebar@gmail.com>
Thu, 14 Feb 2013 02:26:43 -0500
changeset 121845 1cb87cc6b6a8481b86da031329f055f42345de7b
parent 121844 1651dcb623970c926068956c27efa82f6d3e95ea
child 121846 fc2132ad05a1bcbf9e73089a20e4aa22f2ab4c0b
push id22959
push userjlebar@mozilla.com
push dateThu, 14 Feb 2013 07:28:14 +0000
treeherdermozilla-inbound@8cf341d4ccbd [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 =