Bug 1574071: Handle DocAddSizeOf after unlink. r=mccr8
authorKris Maglione <maglione.k@gmail.com>
Thu, 15 Aug 2019 21:43:55 +0000
changeset 488360 673ebee1e845f5fd65c7ae95c2ea4372f10fc037
parent 488359 2fce06fd642bada80669049de12f9b15924c979b
child 488361 791d6cda0dddf0478ba8a13f6cef42177261b309
push id36440
push userncsoregi@mozilla.com
push dateFri, 16 Aug 2019 03:57:48 +0000
treeherdermozilla-central@a58b7dc85887 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmccr8
bugs1574071
milestone70.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 1574071: Handle DocAddSizeOf after unlink. r=mccr8 Under some odd circumstances, the devtools heap snapshot code tries to record a Document after the cycle collector has unlinked it, which leads to a crash when trying to add the size of the (now null) CSS loader. Differential Revision: https://phabricator.services.mozilla.com/D42176
dom/base/Document.cpp
--- a/dom/base/Document.cpp
+++ b/dom/base/Document.cpp
@@ -14046,18 +14046,21 @@ void Document::DocAddSizeOfExcludingThis
   DocumentOrShadowRoot::AddSizeOfExcludingThis(aWindowSizes);
 
   for (auto& sheetArray : mAdditionalSheets) {
     AddSizeOfOwnedSheetArrayExcludingThis(aWindowSizes, sheetArray);
   }
   // Lumping in the loader with the style-sheets size is not ideal,
   // but most of the things in there are in fact stylesheets, so it
   // doesn't seem worthwhile to separate it out.
-  aWindowSizes.mLayoutStyleSheetsSize +=
-      CSSLoader()->SizeOfIncludingThis(aWindowSizes.mState.mMallocSizeOf);
+  // This can be null if we've already been unlinked.
+  if (mCSSLoader) {
+    aWindowSizes.mLayoutStyleSheetsSize +=
+        mCSSLoader->SizeOfIncludingThis(aWindowSizes.mState.mMallocSizeOf);
+  }
 
   aWindowSizes.mDOMOtherSize += mAttrStyleSheet
                                     ? mAttrStyleSheet->DOMSizeOfIncludingThis(
                                           aWindowSizes.mState.mMallocSizeOf)
                                     : 0;
 
   aWindowSizes.mDOMOtherSize += mStyledLinks.ShallowSizeOfExcludingThis(
       aWindowSizes.mState.mMallocSizeOf);