Closed Bug 1427221 Opened 6 years ago Closed 6 years ago

Intermittent Assertion failure: uint8_t(mClass) < mozilla::ArrayLength(sLayoutFrameTypes), at /builds/worker/workspace/build/src/layout/generic/nsIFrame.h:2796

Categories

(Core :: Web Painting, defect, P1)

Unspecified
Linux
defect

Tracking

()

RESOLVED FIXED
mozilla59
Tracking Status
firefox-esr52 --- unaffected
firefox57 --- unaffected
firefox58 --- fixed
firefox59 --- fixed

People

(Reporter: intermittent-bug-filer, Assigned: MatsPalmgren_bugz)

References

Details

(Keywords: assertion, intermittent-failure, Whiteboard: [stockwell fixed:product])

Attachments

(4 files)

This assertion failure is bad because it indicates we are reading off the end of an array. Mats added this assertion in nsIFrame bug 1381405.

  mozilla::LayoutFrameType Type() const {
    MOZ_ASSERT(uint8_t(mClass) < mozilla::ArrayLength(sLayoutFrameTypes));
    return sLayoutFrameTypes[uint8_t(mClass)];
  }
OS: Unspecified → Linux
Priority: P5 → P3
I doubt there's an issue with a valid frame having an invalid mClass.
I suspect the assertion fails because we use a frame that has been
destroyed and is now poisoned.
#01: nsIFrame::Type [layout/generic/nsIFrame.h:2796]
#02: RetainedDisplayListBuilder::AttemptPartialUpdate [layout/painting/RetainedDisplayListBuilder.cpp:756]
#03: nsLayoutUtils::PaintFrame [layout/base/nsLayoutUtils.cpp:3809]
...
Component: Build Config → Layout: Web Painting
Keywords: assertion
Blocks: 1352499
Priority: P3 → P2
This is a regression from bug 1426345.

When we destroy a frame, we call RemoveDisplayItemDataForDeletion, which includes removing references to this frame from the root frame's ModifiedFrameList.

Unfortunately, nsMathMLmfencedFrame's destructor (which runs after this) calls a function which adds it back again, and we end up with a dangling pointer.
Priority: P2 → P1
Assignee: nobody → matt.woodrow
Moving this code to the base class destructor should prevent similar bugs from popping up in other frame types.
Attachment #8940562 - Flags: review?(mats)
Whiteboard: [stockwell needswork]
Comment on attachment 8940562 [details] [diff] [review]
Defer cleaning up the modified state until the last possible opportunity

Doing "complicated" stuff like this in the dtor should be avoided.
I think this bug neatly demonstrates that it's a footgun.

Allow me to suggest an alternative fix...
Attachment #8940562 - Flags: review?(mats) → review-
Attached patch Alternative fixSplinter Review
Overriding DestroyFrom is the right way to do this I think.

I also added an assertion that would have caught this bug earlier.
Attachment #8941025 - Flags: review?(matt.woodrow)
Attachment #8940564 - Flags: review?(mats) → review+
Comment on attachment 8941025 [details] [diff] [review]
Alternative fix

Review of attachment 8941025 [details] [diff] [review]:
-----------------------------------------------------------------

::: layout/generic/nsFrame.cpp
@@ +858,5 @@
> +    if (this != rootFrame) {
> +      nsTArray<nsIFrame*>* modifiedFrames =
> +        rootFrame->GetProperty(nsIFrame::ModifiedFrameList());
> +      if (modifiedFrames) {
> +        MOZ_ASSERT(!modifiedFrames->Contains(this),

Could we also/instead assert(!IsFrameModified()) from the nsFrame dtor?
Attachment #8941025 - Flags: review?(matt.woodrow) → review+
Pushed by mpalmgren@mozilla.com:
https://hg.mozilla.org/integration/mozilla-inbound/rev/3722e968f87b
part 1 - Do nsMathMLmfencedFrame cleanup in DestroyFrom, not in the dtor.  r=mattwoodrow
https://hg.mozilla.org/integration/mozilla-inbound/rev/6397787172eb
part 2 - Change test to fail every time.  r=mats
(In reply to Matt Woodrow (:mattwoodrow) from comment #13)
> Could we also/instead assert(!IsFrameModified()) from the nsFrame dtor?

That assertion would fail:
https://treeherder.mozilla.org/#/jobs?repo=try&revision=c1580c0da1227bf73dce4ececc3936bd8e0503bf

I'm guessing it's because nsIFrame::RemoveDisplayItemDataForDeletion
doesn't call SetFrameIsModified(false).

It doesn't seem super-important to correct the bit there since we're
about to delete the frame anyway, but feel free to file a follow-up
bug if you want.
https://hg.mozilla.org/mozilla-central/rev/3722e968f87b
https://hg.mozilla.org/mozilla-central/rev/6397787172eb
Status: NEW → RESOLVED
Closed: 6 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla59
Matt, could you help to create the uplift request for 58 so that we can fix bug 1428178 accordingly?
Flags: needinfo?(matt.woodrow)
Whiteboard: [stockwell needswork] → [stockwell fixed:product]
Assignee: matt.woodrow → mats
Flags: needinfo?(matt.woodrow) → needinfo?(mats)
Comment on attachment 8941025 [details] [diff] [review]
Alternative fix

Approval Request Comment
[Feature/Bug causing the regression]:bug 1426345
[User impact if declined]:crash
[Is this code covered by automated tests?]:yes
[Has the fix been verified in Nightly?]:yes
[Needs manual test from QE? If yes, steps to reproduce]: no
[List of other uplifts needed for the feature/fix]:
[Is the change risky?]:no
[Why is the change risky/not risky?]:trivial fix
[String changes made/needed]:none
Flags: needinfo?(mats)
Attachment #8941025 - Flags: approval-mozilla-beta?
Comment on attachment 8941025 [details] [diff] [review]
Alternative fix

Fix a regression. Beta58+.
Attachment #8941025 - Flags: approval-mozilla-release+
Attachment #8941025 - Flags: approval-mozilla-beta?
Attachment #8941025 - Flags: approval-mozilla-beta+
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: