Bug 1356276: stylo: Assert that Gecko_CSSFontFaceRule_GetCssText is on the main thread to satisfy heap write analysis; r?bholley draft
authorManish Goregaokar <manishearth@gmail.com>
Thu, 20 Apr 2017 13:33:12 -0700
changeset 566093 3cf6ed6f3f73a50b555bd2bf4f46e61f2d78bc62
parent 566088 d3d4cfe0451b00f5e3486bf9366099768732bd95
child 566201 fe38342440b9ed0cdeb3fdc120e042501c72873f
push id55084
push userbmo:manishearth@gmail.com
push dateThu, 20 Apr 2017 20:33:47 +0000
reviewersbholley
bugs1356276
milestone55.0a1
Bug 1356276: stylo: Assert that Gecko_CSSFontFaceRule_GetCssText is on the main thread to satisfy heap write analysis; r?bholley MozReview-Commit-ID: 3m4fX8eUXe4
layout/style/ServoBindings.cpp
taskcluster/scripts/builder/hazard-analysis.sh
--- a/layout/style/ServoBindings.cpp
+++ b/layout/style/ServoBindings.cpp
@@ -1804,16 +1804,22 @@ Gecko_CSSFontFaceRule_Create()
   RefPtr<nsCSSFontFaceRule> rule = new nsCSSFontFaceRule(0, 0);
   return rule.forget().take();
 }
 
 void
 Gecko_CSSFontFaceRule_GetCssText(const nsCSSFontFaceRule* aRule,
                                  nsAString* aResult)
 {
+  // GetCSSText serializes nsCSSValues, which have a heap write
+  // hazard when dealing with color values (nsCSSKeywords::AddRefTable)
+  // We only serialize on the main thread; assert to convince the analysis
+  // and prevent accidentally calling this elsewhere
+  MOZ_ASSERT(NS_IsMainThread());
+
   aRule->GetCssText(*aResult);
 }
 
 NS_IMPL_FFI_REFCOUNTING(nsCSSFontFaceRule, CSSFontFaceRule);
 
 NS_IMPL_THREADSAFE_FFI_REFCOUNTING(nsCSSValueSharedList, CSSValueSharedList);
 
 #define STYLE_STRUCT(name, checkdata_cb)                                      \
--- a/taskcluster/scripts/builder/hazard-analysis.sh
+++ b/taskcluster/scripts/builder/hazard-analysis.sh
@@ -146,16 +146,16 @@ function check_hazards () {
     echo "TinderboxPrint: heap write hazards<br/>$NUM_WRITE_HAZARDS"
 
     if [ $NUM_HAZARDS -gt 0 ]; then
         echo "TEST-UNEXPECTED-FAIL $NUM_HAZARDS rooting hazards detected" >&2
         echo "TinderboxPrint: documentation<br/><a href='https://wiki.mozilla.org/Javascript:Hazard_Builds#Diagnosing_a_rooting_hazards_failure'>static rooting hazard analysis failures</a>, visit \"Inspect Task\" link for hazard details"
         exit 1
     fi
 
-    NUM_ALLOWED_WRITE_HAZARDS=8
+    NUM_ALLOWED_WRITE_HAZARDS=7
     if [ $NUM_WRITE_HAZARDS -gt $NUM_ALLOWED_WRITE_HAZARDS ]; then
         echo "TEST-UNEXPECTED-FAIL $NUM_WRITE_HAZARDS heap write hazards detected out of $NUM_ALLOWED_WRITE_HAZARDS allowed" >&2
         echo "TinderboxPrint: documentation<br/><a href='https://wiki.mozilla.org/Javascript:Hazard_Builds#Diagnosing_a_heap_write_hazard_failure'>heap write hazard analysis failures</a>, visit \"Inspect Task\" link for hazard details"
         exit 1
     fi
     )
 }