Closed Bug 1326167 Opened 7 years ago Closed 7 years ago

stylo: dom/html/crashtests/795221-1.html leaks

Categories

(Core :: CSS Parsing and Computation, defect)

defect
Not set
normal

Tracking

()

RESOLVED FIXED
mozilla53
Tracking Status
firefox53 --- fixed

People

(Reporter: heycam, Assigned: xidorn)

References

Details

Attachments

(1 file)

One of the crashtest leaks is from dom/html/crashtests/795221-1.html (and its friends), which creates a cycle by setting an expando property on a ServoStyleRule's declaration.

Xidorn, did we get something wrong with the cycle collector stuff there?
Flags: needinfo?(xidorn+moz)
I think the issue here is actually that I didn't hook ServoCSSRuleList into cycle collection. Gecko's CSSRuleList doesn't need special handling because it doesn't own the rules, but ServoCSSRuleList owns the rules, so it does need to trace them.
Assignee: nobody → xidorn+moz
Flags: needinfo?(xidorn+moz)
Comment on attachment 8822582 [details]
Bug 1326167 - Hook ServoStyleSheet and ServoCSSRuleList into cycle collection.

Looks simple enough, but bz was recently poking around at the object model stuff, so he should probably take a look.
Attachment #8822582 - Flags: review?(bobbyholley) → review?(bzbarsky)
Comment on attachment 8822582 [details]
Bug 1326167 - Hook ServoStyleSheet and ServoCSSRuleList into cycle collection.

https://reviewboard.mozilla.org/r/101444/#review103218

r=me

::: layout/style/ServoCSSRuleList.cpp:40
(Diff revision 1)
> +
> +NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN(ServoCSSRuleList)
> +  for (uintptr_t& rule : tmp->mRules) {
> +    if (rule > kMaxRuleType) {
> +      CastToPtr(rule)->Release();
> +      // XXX Do we need to restore the type value here? Is it possible

Probably safest to set the type to 0, yes.  Someone else could poke at it during their own unlinking process...

::: layout/style/ServoCSSRuleList.cpp:48
(Diff revision 1)
> +    }
> +  }
> +NS_IMPL_CYCLE_COLLECTION_UNLINK_END_INHERITED(dom::CSSRuleList)
> +NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN_INHERITED(ServoCSSRuleList,
> +                                                  dom::CSSRuleList)
> +  tmp->EnumerateInstantiatedRules([&](css::Rule* aRule) {

Does this compile down to something reasonable that doesn't involve lots of function calls in practice?

::: layout/style/ServoCSSRuleList.cpp:49
(Diff revision 1)
> +  }
> +NS_IMPL_CYCLE_COLLECTION_UNLINK_END_INHERITED(dom::CSSRuleList)
> +NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN_INHERITED(ServoCSSRuleList,
> +                                                  dom::CSSRuleList)
> +  tmp->EnumerateInstantiatedRules([&](css::Rule* aRule) {
> +    NS_CYCLE_COLLECTION_NOTE_EDGE_NAME(cb, "rule");

I think "mRules[i]" would be a closer match for how we normally represent arrays as CC edge names.

::: layout/style/ServoCSSRuleList.cpp:50
(Diff revision 1)
> +NS_IMPL_CYCLE_COLLECTION_UNLINK_END_INHERITED(dom::CSSRuleList)
> +NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN_INHERITED(ServoCSSRuleList,
> +                                                  dom::CSSRuleList)
> +  tmp->EnumerateInstantiatedRules([&](css::Rule* aRule) {
> +    NS_CYCLE_COLLECTION_NOTE_EDGE_NAME(cb, "rule");
> +    cb.NoteXPCOMChild(aRule->GetExistingDOMRule());

This is going to conflict with the patches in bug 851892 (which remove GetExistingDOMRule), but merging should be easy enough.  Just check that it hasn't landed before you land this.
Attachment #8822582 - Flags: review?(bzbarsky) → review+
Comment on attachment 8822582 [details]
Bug 1326167 - Hook ServoStyleSheet and ServoCSSRuleList into cycle collection.

https://reviewboard.mozilla.org/r/101444/#review103218

> Does this compile down to something reasonable that doesn't involve lots of function calls in practice?

I... don't know. I simply trust that the compiler would do the right thing... and I'm not sure what is the easist way to check that :/
Step through it and see what the assembly actually looks like?  :(
So for VS2015, the compiler inlines the lambda into the instantiated template, but the template function isn't inlined into the traverse function. I guess that is fine as far as we don't do a function call for each rule for traversing.
Pushed by xquan@mozilla.com:
https://hg.mozilla.org/integration/autoland/rev/e8f9f36068ef
Hook ServoStyleSheet and ServoCSSRuleList into cycle collection. r=bz
> I guess that is fine as far as we don't do a function call for each rule

Yes, that's the key part.  Thank you for checking!
https://hg.mozilla.org/mozilla-central/rev/e8f9f36068ef
Status: NEW → RESOLVED
Closed: 7 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla53
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: