Bug 1203430 - Intermittent crash in PNeckoChild::SendHTMLDNSPrefetch. r=jdm, a=ritu
authorJason Duell <jduell.mcbugs@gmail.com>
Wed, 23 Dec 2015 20:00:54 -0500
changeset 310849 bffafd2720162eaa1abf3963b1d9dabe494276be
parent 310848 20d95004d8d18062255a9b4afa37b447b282a248
child 310850 581d9ef0a6b8f05452940b3d758dd0b462083f01
push id5513
push userraliiev@mozilla.com
push dateMon, 25 Jan 2016 13:55:34 +0000
treeherdermozilla-beta@5ee97dd05b5c [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjdm, ritu
bugs1203430
milestone45.0a2
Bug 1203430 - Intermittent crash in PNeckoChild::SendHTMLDNSPrefetch. r=jdm, a=ritu
dom/html/nsHTMLDNSPrefetch.cpp
--- a/dom/html/nsHTMLDNSPrefetch.cpp
+++ b/dom/html/nsHTMLDNSPrefetch.cpp
@@ -135,17 +135,20 @@ nsHTMLDNSPrefetch::PrefetchHigh(Link *aE
 nsresult
 nsHTMLDNSPrefetch::Prefetch(const nsAString &hostname, uint16_t flags)
 {
   if (IsNeckoChild()) {
     // We need to check IsEmpty() because net_IsValidHostName()
     // considers empty strings to be valid hostnames
     if (!hostname.IsEmpty() &&
         net_IsValidHostName(NS_ConvertUTF16toUTF8(hostname))) {
-      gNeckoChild->SendHTMLDNSPrefetch(nsAutoString(hostname), flags);
+      // during shutdown gNeckoChild might be null
+      if (gNeckoChild) {
+        gNeckoChild->SendHTMLDNSPrefetch(nsAutoString(hostname), flags);
+      }
     }
     return NS_OK;
   }
 
   if (!(sInitialized && sDNSService && sPrefetches && sDNSListener))
     return NS_ERROR_NOT_AVAILABLE;
 
   nsCOMPtr<nsICancelable> tmpOutstanding;
@@ -192,18 +195,21 @@ nsHTMLDNSPrefetch::CancelPrefetch(const 
                                   nsresult aReason)
 {
   // Forward this request to Necko Parent if we're a child process
   if (IsNeckoChild()) {
     // We need to check IsEmpty() because net_IsValidHostName()
     // considers empty strings to be valid hostnames
     if (!hostname.IsEmpty() &&
         net_IsValidHostName(NS_ConvertUTF16toUTF8(hostname))) {
-      gNeckoChild->SendCancelHTMLDNSPrefetch(nsString(hostname), flags,
-                                             aReason);
+      // during shutdown gNeckoChild might be null
+      if (gNeckoChild) {
+        gNeckoChild->SendCancelHTMLDNSPrefetch(nsString(hostname), flags,
+                                               aReason);
+      }
     }
     return NS_OK;
   }
 
   if (!(sInitialized && sDNSService && sPrefetches && sDNSListener))
     return NS_ERROR_NOT_AVAILABLE;
 
   // Forward cancellation to DNS service
@@ -321,18 +327,21 @@ nsHTMLDNSPrefetch::nsDeferrals::SubmitQu
           hrefURI->GetAsciiHost(hostName);
           rv = NS_URIChainHasFlags(hrefURI,
                                    nsIProtocolHandler::URI_IS_LOCAL_RESOURCE,
                                    &isLocalResource);
         }
 
         if (!hostName.IsEmpty() && NS_SUCCEEDED(rv) && !isLocalResource) {
           if (IsNeckoChild()) {
-            gNeckoChild->SendHTMLDNSPrefetch(NS_ConvertUTF8toUTF16(hostName),
-                                           mEntries[mTail].mFlags);
+            // during shutdown gNeckoChild might be null
+            if (gNeckoChild) {
+              gNeckoChild->SendHTMLDNSPrefetch(NS_ConvertUTF8toUTF16(hostName),
+                                               mEntries[mTail].mFlags);
+            }
           } else {
             nsCOMPtr<nsICancelable> tmpOutstanding;
 
             rv = sDNSService->AsyncResolve(hostName,
                                            mEntries[mTail].mFlags
                                            | nsIDNSService::RESOLVE_SPECULATE,
                                            sDNSListener, nullptr,
                                            getter_AddRefs(tmpOutstanding));