Bugzilla@Mozilla – Bug 432114
Crash [@ PL_DHashTableOperate][@ nsEditor::EndUpdateViewBatch] with DOMNodeInserted event listener removing window and frameset contenteditable
Last modified: 2009-08-24 04:08:30 PDT
Summon comment box
Created attachment 319272 [details] testcase See testcase, which crashes current trunk build. This regressed between 2008-04-23 and 2008-04-24: http://bonsai.mozilla.org/cvsquery.cgi?treeid=default&module=all&branch=HEAD&branchtype=match&dir=&file=&filetype=match&who=&whotype=match&sortby=Date&hours=2&date=explicit&mindate=2008-04-23+04&maxdate=2008-04-24+09&cvsroot=%2Fcvsroot I think a regression of bug 386782. The data url of the iframe consists of this: <script> window.addEventListener('DOMNodeInserted', function() {window.frameElement.parentNode.removeChild(window.frameElement);}, true); </script> <frameset contenteditable="true"> Useful stack of breakpad (I also get a lot of useless stacks): http://crash-stats.mozilla.com/report/index/a30693b8-19df-11dd-a4f1-001a4bd46e84?p=1 0 xul.dll PL_DHashTableOperate pldhash.c:588 1 xul.dll nsTHashtable<nsBaseHashtableET<nsStringHashKey, nsCOMPtr<nsIDOMStorage> > >::GetEntry nsTHashtable.h:164 2 xul.dll nsClassHashtable<nsUint32HashKey, nsCOMArray<nsXULTemplateResultRDF> >::Get nsClassHashtable.h:101 3 xul.dll nsCommandManager::CommandStatusChanged mozilla/embedding/components/commandhandler/src/nsCommandManager.cpp:127 4 xul.dll nsComposerCommandsUpdater::UpdateCommandGroup mozilla/editor/composer/src/nsComposerCommandsUpdater.cpp:347 5 xul.dll nsComposerCommandsUpdater::UpdateDirtyState mozilla/editor/composer/src/nsComposerCommandsUpdater.cpp:291 6 xul.dll nsComposerCommandsUpdater::NotifyDocumentStateChanged mozilla/editor/composer/src/nsComposerCommandsUpdater.cpp:107 7 xul.dll xul.dll@0x24f93c 8 xul.dll nsEditor::IncrementModificationCount mozilla/editor/libeditor/base/nsEditor.cpp:3877 9 xul.dll nsEditor::DoAfterDoTransaction mozilla/editor/libeditor/base/nsEditor.cpp:4638 10 xul.dll nsEditor::DoTransaction mozilla/editor/libeditor/base/nsEditor.cpp:690 11 xul.dll nsEditor::InsertNode mozilla/editor/libeditor/base/nsEditor.cpp:1393 12 xul.dll nsTextEditRules::CreateBogusNodeIfNeeded mozilla/editor/libeditor/text/nsTextEditRules.cpp:1332 13 xul.dll nsTextEditRules::Init mozilla/editor/libeditor/text/nsTextEditRules.cpp:141 14 xul.dll nsHTMLEditRules::Init mozilla/editor/libeditor/html/nsHTMLEditRules.cpp:252 15 xul.dll nsHTMLEditor::InitRules mozilla/editor/libeditor/html/nsHTMLEditor.cpp:437 16 xul.dll nsPlaintextEditor::EndEditorInit mozilla/editor/libeditor/text/nsPlaintextEditor.cpp:180 17 xul.dll nsAutoEditInitRulesTrigger::~nsAutoEditInitRulesTrigger mozilla/editor/libeditor/text/nsTextEditUtils.cpp:134 18 xul.dll nsHTMLEditor::Init mozilla/editor/libeditor/html/nsHTMLEditor.cpp:344 19 xul.dll nsEditingSession::SetupEditorOnWindow mozilla/editor/composer/src/nsEditingSession.cpp:492 20 xul.dll nsEditingSession::MakeWindowEditable mozilla/editor/composer/src/nsEditingSession.cpp:208
Created attachment 319273 [details] stack from debug build
Works for me now. Martijn can you verify that this is fixed? I guess it was fixed by bug 430624.
Still crashes for me, using: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9pre) Gecko/2008050506 Minefield/3.0pre
I'm also able to get the [@ nsEditor::EndUpdateViewBatch] crash again, with a slightly different testcase, but I think it's related to this.
Created attachment 319545 [details] testcase2 This is crashing for me, with: http://crash-stats.mozilla.com/report/index/46042e05-1b5f-11dd-b224-0013211cbf8a?p=1 0 xul.dll nsEditor::EndUpdateViewBatch mozilla/editor/libeditor/base/nsEditor.cpp:4373 1 xul.dll nsHTMLEditor::EndUpdateViewBatch mozilla/editor/libeditor/html/nsHTMLEditor.cpp:5809 2 xul.dll nsEditor::EndPlaceHolderTransaction mozilla/editor/libeditor/base/nsEditor.cpp:943 3 xul.dll nsAutoPlaceHolderBatch::~nsAutoPlaceHolderBatch mozilla/editor/libeditor/base/nsEditorUtils.h:66 4 xul.dll nsHTMLEditor::InsertBasicBlock mozilla/editor/libeditor/html/nsHTMLEditor.cpp:2715 5 xul.dll nsHTMLEditor::SetParagraphFormat mozilla/editor/libeditor/html/nsHTMLEditor.cpp:2181 6 xul.dll nsCOMPtr<nsIHTMLEditor>::nsCOMPtr<nsIHTMLEditor> nsCOMPtr.h:645 7 xul.dll nsParagraphStateCommand::SetState mozilla/editor/composer/src/nsComposerCommands.cpp:725
Yeah, I can reproduce it now, I think that second testcase is the same. Can you post the contents of the iframe un-data URI'd? The problem (with the first testcase at least) is that when we turn on contentEditable for the frameset, it adds a bogus <br> to the editor contents, which triggers the event handler, which then removes the iframe and destroys and releases everything, then we carry on and use something that was destroyed and crash.
Contents of testcase2 iframe content: <html xmlns="http://www.w3.org/1999/xhtml"> <frameset contenteditable="true"/> <script> function doExecCommand(){ document.execCommand('insertParagraph', false, ''); } setTimeout(doExecCommand,100); window.addEventListener('DOMNodeRemoved', function() {window.frameElement.parentNode.removeChild(window.frameElement);}, true); </script> </html>
Created attachment 320297 [details] [review] v1 PeterV and I worked on this one together, so asking JST for review. These two testcases are actually two slightly different crashes. The crash in testcase 1 is caused by nsWebShell::EnsureCommandHandler() setting WebShell's mCommandManager field, but the commandManager's init is failing, leaving the command manager in an invalid state. We then come along later and try to use its hash table, which isn't init'd, causing the crash. The fix is to only set WebShell's mCommandManager field if it was successfully inititalized. The crash in testcase 2 is caused by the presShell being null for iframe that's been destroyed. So I just added a null check to fix this.
Can the patch be checked in some tree?
Can the patch be checked in?
I was going to add a crashtest first. I get back tomorrow, I'll look at it then.
Comment on attachment 320297 [details] [review] v1 This is still broken. If I apply the patch, testcase2 doesn't cause a crash, but when I add testcase2 as a crashtest, it still crashes with a stack overflow on calls to nsHTMLDocument::EditingStateChanged(). I'll need to do some more work on this...
Maybe testcase2 suffers from bug 446483?
(In reply to comment #13) > Maybe testcase2 suffers from bug 446483? Unfortunately not. With or without that patch, I still get a crash in editor\libeditor\base\crashtests\430624-1.html on Linux, but only if the crashtest window is focused. Yay.
(In reply to comment #14) > I still get a crash in editor\libeditor\base\crashtests\430624-1.html on Linux. I'm off by 1, it was the next test, editor\composer\src\crastests\428844-1.html
Created attachment 345781 [details] [review] With style sheet owner fix The crash was caused by nsHTMLEditor::EnableExistingStyleSheet() calling SetDisabled() on a style sheet. The style sheet has a reference to a document, which is set in nsHTMLEditor::AddOverrideStyleSheet() initially I think, which refers to a deceased document. nsCSSStyleSheet::SetDisabled() tries to addref that, causing the crash. I don't know why this only shows up on Linux when the mouse is over the window... The fix is to change EnableExistingStyleSheet() so that it sets the style sheet's owner to be the document being edited. So we always ensure that the style sheet belongs to our document before we enable it. I've added that change to this patch.
Marking sg:critical based on description in comment 6 although I'm not seeing the crash myself on a Mac.
Nominating for blocking 1.9.1 since there is a patch in progress already.
Peter, can we get a review here?
Comment on attachment 345781 [details] [review] With style sheet owner fix >diff --git a/docshell/base/nsWebShell.cpp b/docshell/base/nsWebShell.cpp >+ nsCOMPtr<nsPICommandUpdater> commandUpdater = do_CreateInstance("@mozilla.org/embedcomp/command-manager;1"); Rewrap. >diff --git a/editor/libeditor/html/nsHTMLEditor.cpp b/editor/libeditor/html/nsHTMLEditor.cpp >@@ -3685,31 +3679,43 @@ nsHTMLEditor::EnableStyleSheet(const nsA > nsCOMPtr<nsICSSStyleSheet> sheet; >+ nsCOMPtr<nsIStyleSheet> isheet = do_QueryInterface(sheet); >+ rv = isheet->SetOwningDocument(doc); Don't think you need isheet, just use sheet (nsICSSStyleSheet inherits from nsIStyleSheet). > nsHTMLEditor::EnableExistingStyleSheet(const nsAString &aURL) >+ nsCOMPtr<nsIStyleSheet> isheet = do_QueryInterface(sheet); >+ rv = isheet->SetOwningDocument(doc); >+ NS_ENSURE_SUCCESS(rv, rv); Same here.
Created attachment 362649 [details] [review] Patch v3 As previous with review comments addressed. r+/sr+ peterv.
Pushed http://hg.mozilla.org/mozilla-central/rev/5302e1700561
*** Bug 476975 has been marked as a duplicate of this bug. ***
Verified fixed, using: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.2a1pre) Gecko/20090224 Minefield/3.2a1pre (.NET CLR 3.5.30729)
Comment on attachment 362649 [details] [review] Patch v3 a1.9.1=dbaron
http://hg.mozilla.org/releases/mozilla-1.9.1/rev/a96758bd69bc
Chris: Can you please port this to 1.9.0? Code freeze for 1.9.0.8 is tomorrow at 11:59pm PDT.
Sure, I'll do that right now.
Created attachment 367695 [details] [review] Patch ported to 1.9.0 branch Patch v3 back ported to 1.9.0 branch (CVS HEAD).
I don't think that my hg access grants me cvs check-in priviledges... So I need someone to check this into 1.9.0 for me please.
Chris: please apply the patch from bug 483589 before checking this into the 1.9.0 branch.
Comment on attachment 367695 [details] [review] Patch ported to 1.9.0 branch Please make the change peterv requested on checkin. Approved for 1.9.0.8, a=dveditz for release-drivers
When I ssh to csv.mozilla.org I get: "Permission denied (publickey,gssapi-with-mic)." So someone else will have to check this and bug 483589 in to 1.9.0.
I checked this and bug 483589 into the 1.9.0 branch.
Verified for 1.9.0.8 with Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.0.8pre) Gecko/2009031805 GranParadiso/3.0.8pre (.NET CLR 3.5.30729). Crash cleanly occurs in 1.9.0.7. Verified for 1.9.1 with Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10.5; en-US; rv:1.9.1b4pre) Gecko/20090323 Shiretoko/3.5b4pre.
introduced post 1.8-branch
dveditz: duplicate bug 476975 needs to be opened, now
dveditz: ping
Chris: Could you possibly take a look at Bug 510662? I think the bug fix here might have caused that regression, it changed that code and it's within the regression range. See Comment 7 in that bug for the code that gets called.
Comment on attachment 362649 [details] [review] Patch v3 >+ // Ensure the style sheet is owned by our document. >+ nsCOMPtr<nsIDocument> doc = do_QueryInterface(mDocWeak); This needs to be do_QueryReferent...