Summary: | Nullptr crash in positionInParentBeforeNode via InsertTextCommand::doApply | ||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Product: | WebKit | Reporter: | Ryosuke Niwa <rniwa> | ||||||||||
Component: | HTML Editing | Assignee: | Frédéric Wang (:fredw) <fred.wang> | ||||||||||
Status: | RESOLVED FIXED | ||||||||||||
Severity: | Normal | CC: | bfulgham, cgarcia, ews-feeder, ews-watchlist, fred.wang, gpoo, mifenton, product-security, rbuis, svillar, webkit-bug-importer, wenson_hsieh | ||||||||||
Priority: | P2 | Keywords: | InRadar | ||||||||||
Version: | WebKit Nightly Build | ||||||||||||
Hardware: | Unspecified | ||||||||||||
OS: | Unspecified | ||||||||||||
Attachments: |
|
Description
Ryosuke Niwa
2021-06-10 03:20:32 PDT
Reproduced with debug build of WebKitTestRunner at r278627. Created attachment 431435 [details]
Patch
From a quick debugging, the <summary> element is detached from the tree in the testcase. Here is a tentative patch that fixes the assert.
Comment on attachment 431435 [details]
Patch
Please add the test for this.
Also, the actual selection isn't orphaned here, is it?
(In reply to Ryosuke Niwa from comment #3) > Please add the test for this. Will do. > Also, the actual selection isn't orphaned here, is it? I guess you mean endingSelection().isOrphan()? Yes, it became orphan here too (see reverse debugging below). Do you mean we should rely on that method instead? (rr) bt #0 0x00007feb1ace29f7 in CRASH_WITH_INFO(...) () at WTF/Headers/wtf/Assertions.h:744 #1 0x00007feb2162f5b7 in WebCore::positionInParentBeforeNode(WebCore::Node*) (node=0x60c0002a7fc0) at ../../Source/WebCore/dom/Position.cpp:1579 #2 0x00007feb218d622b in WebCore::InsertTextCommand::doApply() (this= 0x61200006f340) at ../../Source/WebCore/editing/InsertTextCommand.cpp:177 ... (rr) reverse-f (rr) p showTree(node) *SUMMARY 0x60c0002a7fc0 (renderer (nil)) #document-fragment 0x61200007e940 (renderer (nil)) (needs style recalc) (child needs style recalc) DIV 0x60c0002a8080 (renderer (nil)) SLOT 0x60d000065fc0 (renderer (nil)) BODY 0x60c0002a82c0 (renderer (nil)) Q 0x60c0002a8380 (renderer (nil)) $1 = void (rr) watch -l node->m_parentNode (rr) rc (rr) delete (rr) reverse-f (rr) bt #0 0x00007feb2128da05 in WebCore::ContainerNode::removeBetween(WebCore::Node*, WebCore::Node*, WebCore::Node&) (this=0x60c0002a6a00, previousChild=0x0, nextChild=0x0, oldChild=...) at ../../Source/WebCore/dom/ContainerNode.cpp:655 #1 0x00007feb2129b9a2 in WebCore::ContainerNode::removeNodeWithScriptAssertion(WebCore::Node&, WebCore::ContainerNode::ChildChange::Source) (this=0x60c0002a6a00, childToRemove=..., source=WebCore::ContainerNode::ChildChange::Source::API) at ../../Source/WebCore/dom/ContainerNode.cpp:181 #2 0x00007feb2128d355 in WebCore::ContainerNode::removeChild(WebCore::Node&) (this=0x60c0002a6a00, oldChild=...) at ../../Source/WebCore/dom/ContainerNode.cpp:614 ... #15 0x00007feb218d5f30 in WebCore::InsertTextCommand::doApply() (this=0x61200006f340) at ../../Source/WebCore/editing/InsertTextCommand.cpp:143 ... (rr) b Source/WebCore/editing/InsertTextCommand.cpp:143 Breakpoint 2 at 0x7feb218d5f06: file ../../Source/WebCore/editing/InsertTextCommand.cpp, line 143. (rr) rc Continuing. 143 deleteSelection(false, true, true, false, false); (rr) p endingSelection().isNoneOrOrphaned() $2 = false (rr) p endingSelection().isOrphan() $3 = false (rr) p endingSelection().start().isOrphan() $4 = false (rr) p endingSelection().end().isOrphan() $5 = false (rr) n 147 if (endingSelection().isNone()) (rr) p endingSelection().isNoneOrOrphaned() $6 = true (rr) p endingSelection().isOrphan() $7 = true (rr) p endingSelection().start().isOrphan() $8 = true (rr) p endingSelection().end().isOrphan() $9 = true no, I mean FrameSelection (In reply to Ryosuke Niwa from comment #5) > no, I mean FrameSelection OK, yes after deleteSelection, endingSelection().isOrphan() is true but document().selection().selection().isOrphan() is false. Created attachment 431515 [details]
Patch
(In reply to Frédéric Wang (:fredw) from comment #6) > (In reply to Ryosuke Niwa from comment #5) > > no, I mean FrameSelection > > OK, yes after deleteSelection, endingSelection().isOrphan() is true but > document().selection().selection().isOrphan() is false. Cool. Comment on attachment 431515 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=431515&action=review > LayoutTests/ChangeLog:6 > + Add regression test. This should appear after "reviewed by" line. > Source/WebCore/ChangeLog:7 > + deleteSelection call In InsertTextCommand::doApply() can make the endingSelection() orphan. > + If that happens, exit early to avoid dereferencing a nullptr pointer later. This long description should appear below "reviewed by" line while the bug title & URL should continue to appear above it. Comment on attachment 431515 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=431515&action=review >> LayoutTests/ChangeLog:6 >> + Add regression test. > > This should appear after "reviewed by" line. Oops, I thought about it but got confused with the 'Test:' thing that is put after... Will fix. Created attachment 431521 [details]
Patch
Committed r278930 (238861@main): <https://commits.webkit.org/238861@main> All reviewed patches have been landed. Closing bug and clearing flags on attachment 431521 [details]. |