Closed Bug 1916081 Opened 1 year ago Closed 1 year ago

Crash in [@ mozilla::EditorBase::GetDocument]

Categories

(Core :: DOM: Editor, defect)

defect

Tracking

()

VERIFIED FIXED
132 Branch
Tracking Status
firefox-esr115 --- unaffected
firefox-esr128 --- unaffected
firefox130 --- unaffected
firefox131 + fixed
firefox132 --- verified

People

(Reporter: mccr8, Assigned: masayuki)

References

(Blocks 1 open bug, Regression)

Details

(4 keywords, Whiteboard: [bugmon:bisected,confirmed], [wptsync upstream])

Crash Data

Attachments

(3 files, 1 obsolete file)

Crash report: https://crash-stats.mozilla.org/report/index/792cac96-184a-48ef-a3e1-5f05a0240831

Reason: SIGSEGV / SEGV_MAPERR

Top 10 frames:

0  libxul.so  RefPtr<mozilla::dom::Document>::get() const  mfbt/RefPtr.h:314
0  libxul.so  RefPtr<mozilla::dom::Document>::operator mozilla::dom::Document*() const&  mfbt/RefPtr.h:327
0  libxul.so  mozilla::EditorBase::GetDocument() const  editor/libeditor/EditorBase.h:142
0  libxul.so  mozilla::HTMLEditor::OurWindowHasFocus() const  editor/libeditor/HTMLEditor.cpp:7176
0  libxul.so  mozilla::HTMLEditor::FocusedElementOrDocumentBecomesNotEditable(mozilla::HTML...  editor/libeditor/HTMLEditor.cpp:866
1  libxul.so  mozilla::dom::Document::EditingStateChanged()  dom/base/Document.cpp:6149
2  libxul.so  mozilla::dom::Document::DeferredContentEditableCountChange(mozilla::dom::Elem...  dom/base/Document.cpp:6469
2  libxul.so  mozilla::dom::DeferredContentEditableCountChangeEvent::Run()  dom/base/Document.cpp:6408
3  libxul.so  nsContentUtils::RemoveScriptBlocker()  dom/base/nsContentUtils.cpp:6254
3  libxul.so  mozilla::dom::Document::EndUpdate()  dom/base/Document.cpp:8309

Null deref.

Mostly, but maybe not entirely, on Android.

Assignee: nobody → masayuki
Severity: -- → S3
Status: NEW → ASSIGNED
Attached file testcase.html
Blocks: domino
Flags: in-testsuite?
Keywords: bugmon, testcase

We are seeing this on Windows and Linux as well.

OS: Android → Unspecified

aHTMLEditor may be nullptr and there may have been an HTMLEditor before
it's called. Therefore, it may need to adjust IME state even if aHTMLEditor
is nullptr. So, it should adjust IME state from aDocument which should be
same as aHTMLEditor->GetDocument() if aHTMLEditor is not nullptr.

Note that if IMEStateManager thinks another nsPresContext has focus, it does
not touch IME state. Therefore, it's safe to skip checking the focus state of
the Document.

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

Verified bug as reproducible on mozilla-central 20240903210242-7fa1ed101e24.
Unable to bisect testcase (Unable to launch the start build!):

Start: ff7e2e9adbc1753b1f3e01a3f2eb8a91bb911418 (20230906035121)
End: c2e5212ba8d5ef250196cba1614a97edcbcc0209 (20240901214551)
BuildFlags: BuildFlags(asan=True, tsan=False, debug=False, fuzzing=True, coverage=False, valgrind=False, no_opt=False, fuzzilli=False, nyx=False)

Whiteboard: [bugmon:bisected,confirmed]

aHTMLEditor may be nullptr and there may have been an HTMLEditor before
it's called. Therefore, it may need to adjust IME state even if aHTMLEditor
is nullptr. So, it should adjust IME state from aDocument which should be
same as aHTMLEditor->GetDocument() if aHTMLEditor is not nullptr.

Note that if IMEStateManager thinks another nsPresContext has focus, it does
not touch IME state. Therefore, it's safe to skip checking the focus state of
the Document.

Original Revision: https://phabricator.services.mozilla.com/D220772

Attachment #9422420 - Flags: approval-mozilla-beta?

beta Uplift Approval Request

  • User impact if declined: May see the crash
  • Code covered by automated testing: yes
  • Fix verified in Nightly: no
  • Needs manual QE test: no
  • Steps to reproduce for manual QE testing: Load the test page
  • Risk associated with taking this patch: Low
  • Explanation of risk level: This touches the case when the last "contenteditable" attribute is removed or the designMode is set to off, and major cases are tested by existing tests
  • String changes made/needed: no
  • Is Android affected?: yes
Pushed by masayuki@d-toybox.com: https://hg.mozilla.org/integration/autoland/rev/3138300cf7c8 Make `HTMLEditor::FocusedElementOrDocumentBecomesNotEditable` stop using `aHTMLEditor` at adjusting IME state r=m_kato
Created web-platform-tests PR https://github.com/web-platform-tests/wpt/pull/47953 for changes under testing/web-platform/tests
Whiteboard: [bugmon:bisected,confirmed] → [bugmon:bisected,confirmed], [wptsync upstream]

Backed out for causing Wc failures on replace_documentElement_children_after_window_closed.html

Backout link

Push with failures

Failure log

Flags: needinfo?(masayuki)
Upstream PR was closed without merging
Attachment #9422420 - Attachment is obsolete: true
Attachment #9422420 - Flags: approval-mozilla-beta?

The bug is linked to a topcrash signature, which matches the following criterion:

  • Top 10 AArch64 and ARM crashes on nightly

:masayuki, could you consider increasing the severity of this top-crash bug?

For more information, please visit BugBot documentation.

Flags: needinfo?(masayuki)
Keywords: topcrash

The bug is marked as tracked for firefox131 (beta). However, the bug still has low severity.

:hsinyi, could you please increase the severity for this tracked bug? If you disagree with the tracking decision, please talk with the release managers.

For more information, please visit BugBot documentation.

Flags: needinfo?(htsai)

I'll land the patch soon without the test. It seems that the test is not caused by this bug itself. I checked the testcase with debug build without the patch, but I couldn't reproduce it, but it leads a crash in both builds (with/without the patch) if it runs as a WPT crashtest alone.

If I add it as a WPT crashtest within <iframe>, it works, but it leads a time-out at textarea-will-be-blurred-by-focus-event-listener.html which does not use contenteditable nor designMode, so, the path should not run.

Flags: needinfo?(masayuki)
Pushed by masayuki@d-toybox.com: https://hg.mozilla.org/integration/autoland/rev/f90ebd811545 Make `HTMLEditor::FocusedElementOrDocumentBecomesNotEditable` stop using `aHTMLEditor` at adjusting IME state r=m_kato

aHTMLEditor may be nullptr and there may have been an HTMLEditor before
it's called. Therefore, it may need to adjust IME state even if aHTMLEditor
is nullptr. So, it should adjust IME state from aDocument which should be
same as aHTMLEditor->GetDocument() if aHTMLEditor is not nullptr.

Note that if IMEStateManager thinks another nsPresContext has focus, it does
not touch IME state. Therefore, it's safe to skip checking the focus state of
the Document.

Original Revision: https://phabricator.services.mozilla.com/D220772

Attachment #9422715 - Flags: approval-mozilla-beta?

beta Uplift Approval Request

  • User impact if declined: This fixes a top10 crash
  • Code covered by automated testing: no
  • Fix verified in Nightly: no
  • Needs manual QE test: no
  • Steps to reproduce for manual QE testing: I'm not sure how to reproduce this bug. Written in comment 15, the test case seems not related to the crash
  • Risk associated with taking this patch: Low
  • Explanation of risk level: The crash is caused by nullptr access of null aHTMLEditor. This just avoids to use it, instead, focus check is done by IMEStateManager itself
  • String changes made/needed: no
  • Is Android affected?: yes
Status: ASSIGNED → RESOLVED
Closed: 1 year ago
Resolution: --- → FIXED
Target Milestone: --- → 132 Branch
Severity: S3 → S2
Flags: needinfo?(htsai)

Verified bug as fixed on rev mozilla-central 20240905095820-c20bcb3d61ec.
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
Attachment #9422715 - Flags: approval-mozilla-beta? → approval-mozilla-beta+
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: