Closed Bug 1334047 Opened 8 years ago Closed 8 years ago

Crash when loading any XSLT file from most websites with Assertion failure: mDocGroup->MatchesKey(docGroupKey), at nsDocument.cpp:2985


(Core :: XSLT, defect)

Not set



Tracking Status
firefox52 + fixed
firefox53 + fixed
firefox54 + fixed


(Reporter: cbook, Assigned: ehsan.akhgari)




(Keywords: assertion, crash, regression)

Crash Data


(4 files)

Attached file bughunter stack
Assertion failure: mDocGroup->MatchesKey(docGroupKey), at c:/builds/moz2_slave/m-cen-w32-d-000000000000000000/build/src/dom/base/nsDocument.cpp:2985

found by bughunter reproduced with latest mozilla debug trunk tinderbox windows build on win7

Bughunter data show that Linux and Windows are affected as well as all branches like aurora,beta and trunk

Steps to reproduce:
-> Load
--> Crash on load

also crashes opt builds like
[Tracking Requested - why for this release]

crashes opt and debug builds trunk -> beta

bill, markus: can you take a look ?
Flags: needinfo?(wmccloskey)
Flags: needinfo?(mstange)
Ehsan, Michael, do you guys have any advice? I've never even heard of these functions.
Flags: needinfo?(mstange)
Flags: needinfo?(michael)
Flags: needinfo?(ehsan)
I'll debug.
Flags: needinfo?(ehsan)
The case at hand here is an XSLT document which uses the text output method.  We set up the DocGroup here <> but at that point we have the null principal set on mDocument so we get a DocGroup with an empty key, and then we get to here <> where we call ResetToURI which causes us to get the correct principal under this call stack:

    frame #1: 0x000000011182783f XUL`nsDocument::SetPrincipal(this=0x000000010bbe3000, aNewPrincipal=0x000000010becfce0) + 335 at nsDocument.cpp:2858
    frame #2: 0x0000000111822012 XUL`nsDocument::ResetToURI(this=0x000000010bbe3000, aURI=0x000000010bab3020, aLoadGroup=0x000000010771f020, aPrincipal=0x000000010becfce0) + 1442 at nsDocument.cpp:2092
    frame #3: 0x0000000113bb34da XUL`mozilla::dom::XMLDocument::ResetToURI(this=0x000000010bbe3000, aURI=0x000000010bab3020, aLoadGroup=0x000000010771f020, aPrincipal=0x000000010becfce0) + 138 at XMLDocument.cpp:274
    frame #4: 0x000000011182188e XUL`nsDocument::Reset(this=0x000000010bbe3000, aChannel=0x000000010bbb5800, aLoadGroup=0x000000010771f020) + 334 at nsDocument.cpp:1976
    frame #5: 0x0000000113bb3440 XUL`mozilla::dom::XMLDocument::Reset(this=0x000000010bbe3000, aChannel=0x000000010bbb5800, aLoadGroup=0x000000010771f020) + 48 at XMLDocument.cpp:261
    frame #6: 0x0000000113bc9195 XUL`URIUtils::ResetWithSource(aNewDoc=0x000000010bbe3000, aSourceNode=0x000000010f347000) + 565 at txURIUtils.cpp:77
    frame #7: 0x0000000113c0fd17 XUL`txMozillaTextOutput::createResultDocument(this=0x000000010a70f100, aSourceDocument=0x000000010f347000, aLoadedAsData=false) + 967 at txMozillaTextOutput.cpp:157
    frame #8: 0x0000000113c1756c XUL`txToDocHandlerFactory::createHandlerWith(this=0x00007fff58c778f0, aFormat=0x0000000128257ee0, aHandler=0x00007fff58c77828) + 588 at txMozillaXSLTProcessor.cpp:118
    frame #9: 0x0000000113bfd2b6 XUL`txExecutionState::init(this=0x00007fff58c77968, aNode=0x0000000128194da0, aGlobalParams=0x000000010be60c50) + 198 at txExecutionState.cpp:116

At this point we get the correct principal and compute a non-empty key, and the assertion fails because we have already set up DocGroup.

What's even more interesting is that we have managed ~15 years since this code landed in bug 155578 without a single test case for this.  :(
Assignee: nobody → ehsan
Component: DOM: Content Processes → XSLT
Flags: needinfo?(michael)
See Also: → 1334281
Depends on: 1334320
No longer depends on: 1334320
See Also: → 1334320
See Also: → 1334322
Note that due to bug 1334322, this bug currently won't get triggered when running reftests/crashtest, and due to bug 1334320 it also won't get triggered from reftests/crashtests that have the HTTP annotation in the manifest (since they're served from http://localhost).  Otherwise this would crash us for any XSLT document being loaded.  :(  See for example bp-08817b04-8f18-426f-9e2f-82e2d2170126.

I'll fix those bugs first to see if my hypothesis above is correct.  But this fix should be backported to 52.
Blocks: 1303196
Crash Signature: [@ nsDocument::SetScopeObject]
Keywords: regression
Summary: Assertion failure: mDocGroup->MatchesKey(docGroupKey), at nsDocument.cpp:2985 → Crash when loading any XSLT file from most websites with Assertion failure: mDocGroup->MatchesKey(docGroupKey), at nsDocument.cpp:2985
(Thankfully release is unaffected.)
I just confirmed that fixing bug 1334281 will make our existing crashtests catch this.
See Also: 1334320, 1334322
Tracking for 52 and up, per comment 6.
Blocks: 1334281
See Also: 1334281
Because of bug 1334281 comment 5, I think a good branch fix for this would be removing the assertion.
Attachment #8831158 - Flags: review?(wmccloskey) → review+
Comment on attachment 8831158 [details] [diff] [review]
Remove the release assertion for docgroup keys matching until we fix the code to adhere to this (branch fix)

Approval Request Comment
[Feature/Bug causing the regression]: Bug 1303196.
[User impact if declined]: Crash when visiting most web-hosted XSLT pages.
[Is this code covered by automated tests?]: This patch doesn't need tests.
[Has the fix been verified in Nightly?]: No, this is a branch specific patch disabling an assertion.  We'll land a real fix on trunk.
[Needs manual test from QE? If yes, steps to reproduce]: Np.
[List of other uplifts needed for the feature/fix]: None.
[Is the change risky?]: No.
[Why is the change risky/not risky?]: See above.
[String changes made/needed]: None.
Attachment #8831158 - Flags: approval-mozilla-beta?
Attachment #8831158 - Flags: approval-mozilla-aurora?
Comment on attachment 8831158 [details] [diff] [review]
Remove the release assertion for docgroup keys matching until we fix the code to adhere to this (branch fix)

remove an assertion to fix crash, aurora53+, beta52+
Attachment #8831158 - Flags: approval-mozilla-beta?
Attachment #8831158 - Flags: approval-mozilla-beta+
Attachment #8831158 - Flags: approval-mozilla-aurora?
Attachment #8831158 - Flags: approval-mozilla-aurora+
has problems to apply to beta:

grafting 386896:0411363a0dc7 "Bug 1334047 - Remove the release assertion for docgroup keys matching until we fix the code to adhere to this (branch fix); r=billm a=jcristau"
merging dom/base/nsDocument.cpp
warning: conflicts while merging dom/base/nsDocument.cpp! (edit, then use 'hg resolve --mark')
abort: unresolved conflicts, can't continue
(use 'hg resolve' and 'hg graft --continue')
Tomcats-MacBook-Pro-300:mozilla-central Tomcat
Flags: needinfo?(ehsan)
backed out from aurora for bustage still
Flags: needinfo?(ehsan)
Flags: qe-verify-
Peter, do you think you'll get a chance to review this?  If not can you please suggest someone else?
Flags: needinfo?(peterv)
Attachment #8831156 - Flags: review?(peterv) → review+
Thanks for the review!
Flags: needinfo?(peterv)
Pushed by
Only set the script handling object for XSLT result documents after setting up the principal; r=peterv
Closed: 8 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla54
You need to log in before you can comment on or make changes to this bug.