Bug 1205486 - Release the ImageValues in an nsStyleContext's CSSVariableImageTable entries outside of hashtable methods to avoid re-entrancy problems. r=seth
authorCameron McCormack <cam@mcc.id.au>
Thu, 17 Sep 2015 15:27:02 +1000
changeset 297328 db852503a55f0aefb8f5ab620a8e33ded9f2eb69
parent 297327 c6b0c072e68fd44eb1771e6fd481e20048cde301
child 297329 87bdb5f6b1e64a489bdf841413147b4c38bd27b8
push id962
push userjlund@mozilla.com
push dateFri, 04 Dec 2015 23:28:54 +0000
treeherdermozilla-release@23a2d286e80f [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersseth
bugs1205486
milestone43.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 1205486 - Release the ImageValues in an nsStyleContext's CSSVariableImageTable entries outside of hashtable methods to avoid re-entrancy problems. r=seth
layout/style/CSSVariableImageTable.h
--- a/layout/style/CSSVariableImageTable.h
+++ b/layout/style/CSSVariableImageTable.h
@@ -162,15 +162,29 @@ Add(nsStyleContext* aContext, nsCSSPrope
 
 /**
  * Removes all ImageValues stored in the CSSVariableImageTable for the provided
  * @aContext.
  */
 inline void
 RemoveAll(nsStyleContext* aContext)
 {
-  detail::GetTable().Remove(aContext);
+  // Move all ImageValue references into removedImageList so that we can
+  // release them outside of any hashtable methods.  (If we just call
+  // Remove(aContext) on the table then we can end up calling back
+  // re-entrantly into hashtable methods, as other style contexts
+  // are released.)
+  detail::ImageValueArray removedImages;
+  auto& imageTable = detail::GetTable();
+  auto* perPropertyImageTable = imageTable.Get(aContext);
+  if (perPropertyImageTable) {
+    for (auto it = perPropertyImageTable->Iter(); !it.Done(); it.Next()) {
+      auto* imageList = it.UserData();
+      removedImages.AppendElements(Move(*imageList));
+    }
+  }
+  imageTable.Remove(aContext);
 }
 
 } // namespace CSSVariableImageTable
 } // namespace mozilla
 
 #endif // mozilla_CSSVariableImageTable_h