Closed Bug 1978485 Opened 3 months ago Closed 2 months ago

Assertion failure: forwardScanFromEndResult.GetContent() == wsScannerAtEnd.GetEndReasonContent(), at /builds/worker/checkouts/gecko/editor/libeditor/HTMLEditorDeleteHandler.cpp:7571

Categories

(Core :: DOM: Editor, defect)

defect

Tracking

()

VERIFIED FIXED
143 Branch
Tracking Status
firefox-esr128 --- unaffected
firefox-esr140 --- unaffected
firefox141 --- unaffected
firefox142 --- fixed
firefox143 --- verified

People

(Reporter: tsmith, Assigned: masayuki)

References

(Blocks 1 open bug, Regressed 1 open bug, Regression)

Details

(Keywords: assertion, regression, testcase, Whiteboard: [bugmon:bisected,confirmed], [wptsync upstream])

Attachments

(10 files)

244 bytes, text/html
Details
48 bytes, text/x-phabricator-request
Details | Review
48 bytes, text/x-phabricator-request
Details | Review
48 bytes, text/x-phabricator-request
Details | Review
48 bytes, text/x-phabricator-request
Details | Review
48 bytes, text/x-phabricator-request
Details | Review
48 bytes, text/x-phabricator-request
Details | Review
48 bytes, text/x-phabricator-request
Details | Review
48 bytes, text/x-phabricator-request
Details | Review
48 bytes, text/x-phabricator-request
Details | Review
Attached file testcase.html

Found while fuzzing 20250715-8b4dd515e78c (--enable-debug --enable-fuzzing)

To reproduce via Grizzly Replay:

$ pip install fuzzfetch grizzly-framework --upgrade
$ python -m fuzzfetch -d --fuzzing -n firefox
$ python -m grizzly.replay.bugzilla ./firefox/firefox <bugid>

Assertion failure: forwardScanFromEndResult.GetContent() == wsScannerAtEnd.GetEndReasonContent(), at /builds/worker/checkouts/gecko/editor/libeditor/HTMLEditorDeleteHandler.cpp:7571

#0 0x7ab7b788228e in MOZ_CrashSequence /builds/worker/workspace/obj-build/dist/include/mozilla/Assertions.h:248:3
#1 0x7ab7b788228e in mozilla::Result<mozilla::EditorDOMRangeBase<mozilla::EditorDOMPointBase<nsINode*, nsIContent*>>, nsresult> mozilla::HTMLEditor::AutoDeleteRangesHandler::ExtendOrShrinkRangeToDelete<mozilla::EditorDOMRangeBase<mozilla::EditorDOMPointBase<nsINode*, nsIContent*>>>(mozilla::HTMLEditor const&, mozilla::LimitersAndCaretData const&, mozilla::EditorDOMRangeBase<mozilla::EditorDOMPointBase<nsINode*, nsIContent*>> const&) const /builds/worker/checkouts/gecko/editor/libeditor/HTMLEditorDeleteHandler.cpp:7570:9
#2 0x7ab7b7877d6c in mozilla::HTMLEditor::AutoDeleteRangesHandler::HandleDeleteNonCollapsedRanges(mozilla::HTMLEditor&, short, short, mozilla::AutoClonedSelectionRangeArray&, mozilla::HTMLEditor::AutoDeleteRangesHandler::SelectionWasCollapsed, mozilla::dom::Element const&) /builds/worker/checkouts/gecko/editor/libeditor/HTMLEditorDeleteHandler.cpp:2996:50
#3 0x7ab7b7870ba0 in mozilla::HTMLEditor::AutoDeleteRangesHandler::Run(mozilla::HTMLEditor&, short, short, mozilla::AutoClonedSelectionRangeArray&, mozilla::dom::Element const&) /builds/worker/checkouts/gecko/editor/libeditor/HTMLEditorDeleteHandler.cpp:1204:47
#4 0x7ab7b787016a in mozilla::HTMLEditor::HandleDeleteSelection(short, short) /builds/worker/checkouts/gecko/editor/libeditor/HTMLEditorDeleteHandler.cpp:506:61
#5 0x7ab7b7790b84 in mozilla::EditorBase::DeleteSelectionAsSubAction(short, short) /builds/worker/checkouts/gecko/editor/libeditor/EditorBase.cpp:4862:9
#6 0x7ab7b782d436 in mozilla::HTMLEditor::DeleteSelectionAndPrepareToCreateNode() /builds/worker/checkouts/gecko/editor/libeditor/HTMLEditor.cpp:6431:9
#7 0x7ab7b784ff83 in mozilla::HTMLEditor::HTMLWithContextInserter::Run(nsTSubstring<char16_t> const&, nsTSubstring<char16_t> const&, nsTSubstring<char16_t> const&, mozilla::EditorBase::SafeToInsertData, mozilla::HTMLEditor::InlineStylesAtInsertionPoint) /builds/worker/checkouts/gecko/editor/libeditor/HTMLEditorDataTransfer.cpp:745:22
#8 0x7ab7b784ee51 in mozilla::HTMLEditor::InsertHTMLWithContextAsSubAction(nsTSubstring<char16_t> const&, nsTSubstring<char16_t> const&, nsTSubstring<char16_t> const&, nsTSubstring<char16_t> const&, mozilla::EditorBase::SafeToInsertData, mozilla::EditorDOMPointBase<nsCOMPtr<nsINode>, nsCOMPtr<nsIContent>> const&, mozilla::EditorBase::DeleteSelectedContent, mozilla::HTMLEditor::InlineStylesAtInsertionPoint, mozilla::dom::Element const&) /builds/worker/checkouts/gecko/editor/libeditor/HTMLEditorDataTransfer.cpp:657:71
#9 0x7ab7b784b6cc in mozilla::HTMLEditor::InsertHTMLAsAction(nsTSubstring<char16_t> const&, nsIPrincipal*) /builds/worker/checkouts/gecko/editor/libeditor/HTMLEditorDataTransfer.cpp:347:8
#10 0x7ab7b784ba42 in mozilla::InsertHTMLCommand::DoCommandParam(mozilla::Command, nsTSubstring<char16_t> const&, mozilla::EditorBase&, nsIPrincipal*) const /builds/worker/checkouts/gecko/editor/libeditor/HTMLEditorCommands.cpp:1201:34
#11 0x7ab7b3b7afd1 in mozilla::dom::Document::ExecCommand(nsTSubstring<char16_t> const&, bool, mozilla::dom::TrustedHTMLOrString const&, nsIPrincipal&, mozilla::ErrorResult&) /builds/worker/checkouts/gecko/dom/base/Document.cpp:5798:27
#12 0x7ab7b4ca6cb0 in mozilla::dom::Document_Binding::execCommand(JSContext*, JS::Handle<JSObject*>, void*, JSJitMethodCallArgs const&) /builds/worker/workspace/obj-build/dom/bindings/./DocumentBinding.cpp:4181:36
#13 0x7ab7b4f85a6d in bool mozilla::dom::binding_detail::GenericMethod<mozilla::dom::binding_detail::NormalThisPolicy, mozilla::dom::binding_detail::ThrowExceptions>(JSContext*, unsigned int, JS::Value*) /builds/worker/checkouts/gecko/dom/bindings/BindingUtils.cpp:3306:13
#14 0x7ab7b87edfb4 in CallJSNative(JSContext*, bool (*)(JSContext*, unsigned int, JS::Value*), js::CallReason, JS::CallArgs const&) /builds/worker/checkouts/gecko/js/src/vm/Interpreter.cpp:501:13
#15 0x7ab7b87ed80f in js::InternalCallOrConstruct(JSContext*, JS::CallArgs const&, js::MaybeConstruct, js::CallReason) /builds/worker/checkouts/gecko/js/src/vm/Interpreter.cpp:597:12
#16 0x7ab7b8801438 in CallFromStack /builds/worker/checkouts/gecko/js/src/vm/Interpreter.cpp:669:10
#17 0x7ab7b8801438 in js::Interpret(JSContext*, js::RunState&) /builds/worker/checkouts/gecko/js/src/vm/Interpreter.cpp:3287:16
#18 0x7ab7b87ece73 in js::RunScript(JSContext*, js::RunState&) /builds/worker/checkouts/gecko/js/src/vm/Interpreter.cpp:471:13
#19 0x7ab7b87ed835 in js::InternalCallOrConstruct(JSContext*, JS::CallArgs const&, js::MaybeConstruct, js::CallReason) /builds/worker/checkouts/gecko/js/src/vm/Interpreter.cpp:629:13
#20 0x7ab7b87eec5c in js::Call(JSContext*, JS::Handle<JS::Value>, JS::Handle<JS::Value>, js::AnyInvokeArgs const&, JS::MutableHandle<JS::Value>, js::CallReason) /builds/worker/checkouts/gecko/js/src/vm/Interpreter.cpp:696:8
#21 0x7ab7b88d44eb in JS::Call(JSContext*, JS::Handle<JS::Value>, JS::Handle<JS::Value>, JS::HandleValueArray const&, JS::MutableHandle<JS::Value>) /builds/worker/checkouts/gecko/js/src/vm/CallAndConstruct.cpp:119:10
#22 0x7ab7b420f758 in mozilla::dom::MutationCallback::Call(mozilla::dom::BindingCallContext&, JS::Handle<JS::Value>, mozilla::dom::Sequence<mozilla::OwningNonNull<nsDOMMutationRecord>> const&, nsDOMMutationObserver&, mozilla::ErrorResult&) /builds/worker/workspace/obj-build/dom/bindings/./MutationObserverBinding.cpp:99:8
#23 0x7ab7b3df5e84 in void mozilla::dom::MutationCallback::Call<nsDOMMutationObserver*>(nsDOMMutationObserver* const&, mozilla::dom::Sequence<mozilla::OwningNonNull<nsDOMMutationRecord>> const&, nsDOMMutationObserver&, mozilla::ErrorResult&, char const*, mozilla::dom::CallbackObjectBase::ExceptionHandling, JS::Realm*) /builds/worker/workspace/obj-build/dist/include/mozilla/dom/MutationObserverBinding.h:79:12
#24 0x7ab7b3de384f in void mozilla::dom::MutationCallback::Call<nsDOMMutationObserver*>(nsDOMMutationObserver* const&, mozilla::dom::Sequence<mozilla::OwningNonNull<nsDOMMutationRecord>> const&, nsDOMMutationObserver&, char const*) /builds/worker/workspace/obj-build/dist/include/mozilla/dom/MutationObserverBinding.h:101:12
#25 0x7ab7b3de3553 in nsDOMMutationObserver::HandleMutation() /builds/worker/checkouts/gecko/dom/base/nsDOMMutationObserver.cpp:818:13
#26 0x7ab7b3de0e0d in nsDOMMutationObserver::HandleMutationsInternal(mozilla::AutoSlowOperation&) /builds/worker/checkouts/gecko/dom/base/nsDOMMutationObserver.cpp:847:26
#27 0x7ab7b1bbceb8 in mozilla::CycleCollectedJSContext::PerformMicroTaskCheckPoint(bool) /builds/worker/checkouts/gecko/xpcom/base/CycleCollectedJSContext.cpp:879:17
#28 0x7ab7b4f99fd5 in LeaveMicroTask /builds/worker/workspace/obj-build/dist/include/mozilla/CycleCollectedJSContext.h:250:7
#29 0x7ab7b4f99fd5 in mozilla::dom::CallbackObjectBase::CallSetup::~CallSetup() /builds/worker/checkouts/gecko/dom/bindings/CallbackObject.cpp:394:11
#30 0x7ab7b513623c in mozilla::dom::BlobCallback::Call(mozilla::dom::Blob*, mozilla::ErrorResult&, char const*, mozilla::dom::CallbackObjectBase::ExceptionHandling, JS::Realm*) /builds/worker/workspace/obj-build/dist/include/mozilla/dom/HTMLCanvasElementBinding.h:91:3
#31 0x7ab7b5a6ae2f in mozilla::dom::BlobCallback::Call(mozilla::dom::Blob*, char const*) /builds/worker/workspace/obj-build/dist/include/mozilla/dom/HTMLCanvasElementBinding.h:103:12
#32 0x7ab7b4fafeee in operator()<StoreRefPtrPassByPtr<mozilla::dom::AsyncIterableIterator<mozilla::dom::TestInterfaceAsyncIterableDouble> > &, StoreRefPtrPassByPtr<mozilla::dom::Promise> &> /builds/worker/workspace/obj-build/dist/include/nsThreadUtils.h:1085:18
#33 0x7ab7b4fafeee in __invoke_impl<void, (lambda at /builds/worker/workspace/obj-build/dist/include/nsThreadUtils.h:1084:9), StoreRefPtrPassByPtr<mozilla::dom::AsyncIterableIterator<mozilla::dom::TestInterfaceAsyncIterableDouble> > &, StoreRefPtrPassByPtr<mozilla::dom::Promise> &> /builds/worker/fetches/sysroot-x86_64-linux-gnu/usr/lib/gcc/x86_64-linux-gnu/8/../../../../include/c++/8/bits/invoke.h:60:14
#34 0x7ab7b4fafeee in __invoke<(lambda at /builds/worker/workspace/obj-build/dist/include/nsThreadUtils.h:1084:9), StoreRefPtrPassByPtr<mozilla::dom::AsyncIterableIterator<mozilla::dom::TestInterfaceAsyncIterableDouble> > &, StoreRefPtrPassByPtr<mozilla::dom::Promise> &> /builds/worker/fetches/sysroot-x86_64-linux-gnu/usr/lib/gcc/x86_64-linux-gnu/8/../../../../include/c++/8/bits/invoke.h:95:14
#35 0x7ab7b4fafeee in __apply_impl<(lambda at /builds/worker/workspace/obj-build/dist/include/nsThreadUtils.h:1084:9), std::tuple<StoreRefPtrPassByPtr<mozilla::dom::AsyncIterableIterator<mozilla::dom::TestInterfaceAsyncIterableDouble> >, StoreRefPtrPassByPtr<mozilla::dom::Promise> > &, 0UL, 1UL> /builds/worker/fetches/sysroot-x86_64-linux-gnu/usr/lib/gcc/x86_64-linux-gnu/8/../../../../include/c++/8/tuple:1678:14
#36 0x7ab7b4fafeee in apply<(lambda at /builds/worker/workspace/obj-build/dist/include/nsThreadUtils.h:1084:9), std::tuple<StoreRefPtrPassByPtr<mozilla::dom::AsyncIterableIterator<mozilla::dom::TestInterfaceAsyncIterableDouble> >, StoreRefPtrPassByPtr<mozilla::dom::Promise> > &> /builds/worker/fetches/sysroot-x86_64-linux-gnu/usr/lib/gcc/x86_64-linux-gnu/8/../../../../include/c++/8/tuple:1687:14
#37 0x7ab7b4fafeee in apply<mozilla::dom::TestInterfaceAsyncIterableDouble, void (mozilla::dom::TestInterfaceAsyncIterableDouble::*)(mozilla::dom::AsyncIterableIterator<mozilla::dom::TestInterfaceAsyncIterableDouble> *, mozilla::dom::Promise *)> /builds/worker/workspace/obj-build/dist/include/nsThreadUtils.h:1083:12
#38 0x7ab7b4fafeee in mozilla::detail::RunnableMethodImpl<mozilla::scache::StartupCache*, void (mozilla::scache::StartupCache::*)(unsigned char*, unsigned long), true, (mozilla::RunnableKind)0, unsigned char*, unsigned long>::Run() /builds/worker/workspace/obj-build/dist/include/nsThreadUtils.h:1134:13
#39 0x7ab7b1cc6847 in mozilla::RunnableTask::Run() /builds/worker/checkouts/gecko/xpcom/threads/TaskController.cpp:703:16
#40 0x7ab7b1cbf94e in mozilla::TaskController::DoExecuteNextTaskOnlyMainThreadInternal(mozilla::detail::BaseAutoLock<mozilla::Mutex&> const&) /builds/worker/checkouts/gecko/xpcom/threads/TaskController.cpp:1310:20
#41 0x7ab7b1cbe687 in mozilla::TaskController::ExecuteNextTaskOnlyMainThreadInternal(mozilla::detail::BaseAutoLock<mozilla::Mutex&> const&) /builds/worker/checkouts/gecko/xpcom/threads/TaskController.cpp:1133:15
#42 0x7ab7b1cbeb05 in mozilla::TaskController::ProcessPendingMTTask(bool) /builds/worker/checkouts/gecko/xpcom/threads/TaskController.cpp:639:36
#43 0x7ab7b1ccd886 in operator() /builds/worker/checkouts/gecko/xpcom/threads/TaskController.cpp:333:37
#44 0x7ab7b1ccd886 in mozilla::detail::RunnableFunction<mozilla::TaskController::TaskController()::$_0>::Run() /builds/worker/checkouts/gecko/xpcom/threads/nsThreadUtils.h:548:5
#45 0x7ab7b1cdf483 in nsThread::ProcessNextEvent(bool, bool*) /builds/worker/checkouts/gecko/xpcom/threads/nsThread.cpp:1159:16
#46 0x7ab7b1ce5baf in NS_ProcessNextEvent(nsIThread*, bool) /builds/worker/checkouts/gecko/xpcom/threads/nsThreadUtils.cpp:480:10
#47 0x7ab7b289c557 in mozilla::ipc::MessagePump::Run(base::MessagePump::Delegate*) /builds/worker/checkouts/gecko/ipc/glue/MessagePump.cpp:85:21
#48 0x7ab7b27f8471 in RunHandler /builds/worker/checkouts/gecko/ipc/chromium/src/base/message_loop.cc:362:3
#49 0x7ab7b27f8471 in MessageLoop::Run() /builds/worker/checkouts/gecko/ipc/chromium/src/base/message_loop.cc:344:3
#50 0x7ab7b7662568 in nsBaseAppShell::Run() /builds/worker/checkouts/gecko/widget/nsBaseAppShell.cpp:148:27
#51 0x7ab7b77263a4 in nsAppShell::Run() /builds/worker/checkouts/gecko/widget/gtk/nsAppShell.cpp:471:33
#52 0x7ab7b864d85b in XRE_RunAppShell() /builds/worker/checkouts/gecko/toolkit/xre/nsEmbedFunctions.cpp:647:20
#53 0x7ab7b289d404 in mozilla::ipc::MessagePumpForChildProcess::Run(base::MessagePump::Delegate*) /builds/worker/checkouts/gecko/ipc/glue/MessagePump.cpp:235:9
#54 0x7ab7b27f8471 in RunHandler /builds/worker/checkouts/gecko/ipc/chromium/src/base/message_loop.cc:362:3
#55 0x7ab7b27f8471 in MessageLoop::Run() /builds/worker/checkouts/gecko/ipc/chromium/src/base/message_loop.cc:344:3
#56 0x7ab7b864ccb2 in XRE_InitChildProcess(int, char**, XREChildData const*) /builds/worker/checkouts/gecko/toolkit/xre/nsEmbedFunctions.cpp:585:34
#57 0x585f382bda2f in main /builds/worker/checkouts/gecko/browser/app/nsBrowserApp.cpp:397:22

Verified bug as reproducible on mozilla-central 20250721154325-bca22a6d0402.
The bug appears to have been introduced in the following build range:

Start: ca1cc5350282d2e1047872fb126704505db5e97a (20250715041850)
End: b8a0a82c42cd974169ed44f393c8e49f628cda6a (20250715013234)
Pushlog: https://hg.mozilla.org/mozilla-central/pushloghtml?fromchange=ca1cc5350282d2e1047872fb126704505db5e97a&tochange=b8a0a82c42cd974169ed44f393c8e49f628cda6a

Keywords: regression
Whiteboard: [bugmon:bisected,confirmed]
Assignee: nobody → masayuki
Severity: -- → S3
Status: NEW → ASSIGNED
OS: Unspecified → All
Regressed by: 1976608
Hardware: Unspecified → All

Well, the assertion is now wrong. So, this does not affect to the users. However, I think similar mismatching must have occurred at the GetEndReasonContent() or GetStartReasonContent() callers.

Well, I think bug 1976608 should be backed out only from beta branch later.

Set release status flags based on info from the regressing bug 1976608

Marking 142 as fixed by backout because the regressor (bug 1976608) was backed out beta for 142.0b2.

Starting from bug 1976608,
WSRunScanner::ScanInclusiveNextVisibleNodeOrBlockBoundaryFrom()
started ignoring invisible Comment nodes. Therefore, the result
may be different from its end reason content. So, the assertion is now
invalid.

It's unused and it does wrong thing to get the following invisible
<br> element. So, it should be deleted.

The method should use
WSRunScanner::ScanPreviousVisibleNodeOrBlockBoundaryFrom() and
WSRunScanner::ScanInclusiveNextVisibleNodeOrBlockBoundaryFrom()
instead of the reason content of WSRunScanner.

They should be used only when the caller needs to call both
ScanPreviousVisibleNodeOrBlockBoundary and
ScanPreviousVisibleNodeOrBlockBoundary or referring/calling other
methods of WSRunScanner to skip scanning the surrounding content
twice or more.

This changes the scan start point of the second call because it's odd
that it scans from after the preceding invisible <br> element.

Target Milestone: 143 Branch → ---
Pushed by masayuki@d-toybox.com: https://github.com/mozilla-firefox/firefox/commit/357c5d71a446 https://hg.mozilla.org/integration/autoland/rev/6750ca938769 part 1: Delete the assertion in `HTMLEditor::AutoDeleteRangesHandler::ExtendOrShrinkRangeToDelete()` r=m_kato https://github.com/mozilla-firefox/firefox/commit/4823105fb211 https://hg.mozilla.org/integration/autoland/rev/2be028a50381 part 2: Get rid of `HTMLWithContextInserter::GetInvisibleBRElementAtPoint()` r=m_kato https://github.com/mozilla-firefox/firefox/commit/6c3bc6aa5e4c https://hg.mozilla.org/integration/autoland/rev/78a4e370c999 part 3: Rewrite `AutoDeleteRangesHandler::DeleteParentBlocksWithTransactionIfEmpty()` r=m_kato
Created web-platform-tests PR https://github.com/web-platform-tests/wpt/pull/54036 for changes under testing/web-platform/tests
Whiteboard: [bugmon:bisected,confirmed] → [bugmon:bisected,confirmed], [wptsync upstream]
Pushed by masayuki@d-toybox.com: https://github.com/mozilla-firefox/firefox/commit/8da4cf2d9d57 https://hg.mozilla.org/integration/autoland/rev/0e5cc7fef2d6 part 4: Rewrite `AutoDeleteRangesHandler::ExtendOrShrinkRangeToDelete` to use `WSRunScanner::ScanInclusiveNextVisibleNodeOrBlockBoundary` r=m_kato
Pushed by masayuki@d-toybox.com: https://github.com/mozilla-firefox/firefox/commit/9647f22cca90 https://hg.mozilla.org/integration/autoland/rev/402ec19b1b9b part 5: Make some `WSRunScanner::Scan(Previous|InclusiveNext)VisibleNodeOrBlockBoundaryFrom` users use the static versions directly r=m_kato
Pushed by masayuki@d-toybox.com: https://github.com/mozilla-firefox/firefox/commit/13e1ee349c8b https://hg.mozilla.org/integration/autoland/rev/524457610691 part 6: Make `HTMLWithContextInserter::GetNewCaretPointAfterInsertingHTML` use `WSRunScanner::ScanPreviousVisibleNodeOrBlockBoundary` directly r=m_kato
Pushed by masayuki@d-toybox.com: https://github.com/mozilla-firefox/firefox/commit/7d8e5d6bf45a https://hg.mozilla.org/integration/autoland/rev/911cfdaf6659 part 7: Make `AutoInsertLineBreakHandler::InsertLinefeed` use `Scan(Previous|InclusiveNext)VisibleNodeOrBlockBoundaryFrom` r=m_kato
Pushed by masayuki@d-toybox.com: https://github.com/mozilla-firefox/firefox/commit/5b26a41fccee https://hg.mozilla.org/integration/autoland/rev/fbb1c2043f73 part 8: Make `HTMLEditor::GetRangeExtendedToHardLineEdgesForBlockEditAction` use `Scan(Previous|InclusiveNext)VisibleNodeOrBlockBoundary` directly r=m_kato https://github.com/mozilla-firefox/firefox/commit/819d86c06142 https://hg.mozilla.org/integration/autoland/rev/556836c3c1da part 9: Get rid of accessors of start/end reason of the scan start point of `WSRunScanner` r=m_kato
Upstream PR merged by moz-wptsync-bot

Verified bug as fixed on rev mozilla-central 20250730092527-320fe0da2b9f.
Removing bugmon keyword as no further action possible. Please review the bug and re-add the keyword for further analysis.

Status: RESOLVED → VERIFIED
Keywords: bugmon
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: