Bug 1514488 - Check if IPC still opens before sending classify result. r=baku
authorDimi Lee <dlee@mozilla.com>
Mon, 14 Jan 2019 08:24:39 +0000
changeset 453719 710ac2f726a1945a81fc5bb6fe98fd3ffce1046f
parent 453718 93c4e08b14fc730afbb76884b6e050ba6b1322ae
child 453720 29b9eaabfca3c750633854959c339c8c64e9b087
push id111141
push userncsoregi@mozilla.com
push dateMon, 14 Jan 2019 17:26:52 +0000
treeherdermozilla-inbound@b8baa741549c [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbaku
bugs1514488, 1514202
milestone66.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 1514488 - Check if IPC still opens before sending classify result. r=baku The crash happens when parent process tries to send classify result to the content process while the IPC connection is already closed. The only case that we needs IPC for classification is for Flash classification, but flash classification is moved to parent process after Bug 1514202. Although right now there is no consumer for the IPC version of nsUrlClassifierDBService::AsyncClassifyLocalWithFeatures, we should still fix this bug. Differential Revision: https://phabricator.services.mozilla.com/D16362
dom/ipc/URLClassifierParent.cpp
--- a/dom/ipc/URLClassifierParent.cpp
+++ b/dom/ipc/URLClassifierParent.cpp
@@ -156,23 +156,25 @@ mozilla::ipc::IPCResult URLClassifierLoc
   }
 
   return IPC_OK();
 }
 
 NS_IMETHODIMP
 URLClassifierLocalParent::OnClassifyComplete(
     const nsTArray<RefPtr<nsIUrlClassifierFeatureResult>>& aResults) {
-  nsTArray<URLClassifierLocalResult> ipcResults;
-  for (nsIUrlClassifierFeatureResult* result : aResults) {
-    URLClassifierLocalResult* ipcResult = ipcResults.AppendElement();
+  if (mIPCOpen) {
+    nsTArray<URLClassifierLocalResult> ipcResults;
+    for (nsIUrlClassifierFeatureResult* result : aResults) {
+      URLClassifierLocalResult* ipcResult = ipcResults.AppendElement();
 
-    net::UrlClassifierFeatureResult* r =
-        static_cast<net::UrlClassifierFeatureResult*>(result);
+      net::UrlClassifierFeatureResult* r =
+          static_cast<net::UrlClassifierFeatureResult*>(result);
 
-    ipcResult->uri() = r->URI();
-    r->Feature()->GetName(ipcResult->featureName());
-    ipcResult->matchingList() = r->List();
+      ipcResult->uri() = r->URI();
+      r->Feature()->GetName(ipcResult->featureName());
+      ipcResult->matchingList() = r->List();
+    }
+
+    Unused << Send__delete__(this, ipcResults);
   }
-
-  Unused << Send__delete__(this, ipcResults);
   return NS_OK;
 }