Closed Bug 1989891 Opened 6 months ago Closed 6 months ago

Crash in [@ mozilla::dom::TextDirectiveUtil::ComputeCommonSubstringLength<T>]

Categories

(Core :: DOM: Navigation, defect, P3)

Unspecified
All
defect

Tracking

()

RESOLVED FIXED
145 Branch
Tracking Status
firefox-esr115 --- unaffected
firefox-esr140 --- unaffected
firefox143 --- unaffected
firefox144 --- disabled
firefox145 + fixed

People

(Reporter: aryx, Assigned: jjaschke)

References

(Regression)

Details

(Keywords: crash, regression, topcrash)

Crash Data

Attachments

(1 file)

Similar to bug 1987845 after bug 1979588 relanded but with reduced crash volume.

Crash report: https://crash-stats.mozilla.org/report/index/85998ad3-d168-407b-b2bb-453450250910

MOZ_CRASH Reason:

MOZ_DIAGNOSTIC_ASSERT(!nsContentUtils::IsHTMLWhitespace(aReferenceString.First()))

Top 10 frames:

0  xul.dll  mozilla::dom::TextDirectiveUtil::ComputeCommonSubstringLength<-1>(nsTSubstrin...  dom/base/TextDirectiveUtil.h:554
1  xul.dll  mozilla::dom::RangeBasedTextDirectiveCreator::FindEndMatchCommonSubstringLeng...  dom/base/TextDirectiveCreator.cpp:624
2  xul.dll  mozilla::dom::RangeBasedTextDirectiveCreator::FindAllMatchingCandidates()  dom/base/TextDirectiveCreator.cpp:575
3  xul.dll  mozilla::dom::TextDirectiveCreator::CreateTextDirectiveFromRange(mozilla::dom...  dom/base/TextDirectiveCreator.cpp:57
4  xul.dll  mozilla::dom::FragmentDirective::CreateTextDirectiveForRanges(mozilla::dom::S...  dom/base/FragmentDirective.cpp:465
5  xul.dll  mozilla::dom::FragmentDirective_Binding::createTextDirectiveForRanges(JSConte...  dom/bindings/FragmentDirectiveBinding.cpp:194
5  xul.dll  mozilla::dom::FragmentDirective_Binding::createTextDirectiveForRanges_promise...  dom/bindings/FragmentDirectiveBinding.cpp:205
6  xul.dll  mozilla::dom::binding_detail::GenericMethod<mozilla::dom::binding_detail::Nor...  dom/bindings/BindingUtils.cpp:3308
7  xul.dll  CallJSNative(JSContext*, bool (*)(JSContext*, unsigned int, JS::Value*), js::...  js/src/vm/Interpreter.cpp:501
7  xul.dll  js::InternalCallOrConstruct(JSContext*, JS::CallArgs const&, js::MaybeConstru...  js/src/vm/Interpreter.cpp:597
Flags: needinfo?(jjaschke)

This is diagnostic assertion only.

Severity: -- → S3
Priority: -- → P3

The bug is marked as tracked for firefox145 (nightly). However, the bug still isn't assigned, has low priority and has low severity.

:hsinyi, could you please find an assignee, increase the priority and increase the severity for this tracked bug? Given that it is a regression and we know the cause, we could also simply backout the regressor. If you disagree with the tracking decision, please talk with the release managers.

For more information, please visit BugBot documentation.

Flags: needinfo?(htsai)

This is a diagnostic assert. I'm still trying to reproduce. The "regressor" changed the asserts from MOZ_ASSERT to MOZ_DIAGNOSTIC_ASSERT. So it's not really a regression.

Flags: needinfo?(jjaschke)
Flags: needinfo?(htsai)
Crash Signature: [@ mozilla::dom::TextDirectiveUtil::ComputeCommonSubstringLength<T> ]

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

For more information, please visit BugBot documentation.

Flags: needinfo?(smaug)

Yes. This is still a very common issue.
jjaschke, I think the assertion should be changed to MOZ_ASSERT or something rather soon.

Severity: S3 → S2
Flags: needinfo?(smaug) → needinfo?(jjaschke)

I can reproduce the crash with a page that has this content:

test 1 1111111111111
1111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111
1111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111
1111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111
1111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111
1111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111
1111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111
1111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111
1111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111
1111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111
1111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111
test

When selecting the "test" at the end and then right-clicking.

The algorithm collects surrounding prefix and suffix text around the target range. Then it collects all other matches for the target range in the document, and compares the surrounding text of these matches to the prefix and suffix, to determine the length of the common substrings.
These prefix and suffix terms are cut off arbitrarily at a certain length (1024 chars) to avoid doing too much work -- if the first 1024 chars of a prefix and suffix are equal between the target range and a match, we give up (the URLs would become much too long in that case as well).

The code here cuts off at 1024 chars, but doesn't account for whitespace - if it happens that at that exact cutoff position there is whitespace, we run into the assert. The test case above does exactly that. After 1024 characters (reading from the right, because this is prefix) there is a whitespace character, so that the cutoff prefix consists of a whitespace followed by 1023 "1"; the same happens for the suffix code.

The fix is trivial -- don't cutoff at 1024 chars, but instead at a word boundary.

Flags: needinfo?(jjaschke)
Assignee: nobody → jjaschke
Status: NEW → ASSIGNED
Pushed by jjaschke@mozilla.com: https://github.com/mozilla-firefox/firefox/commit/c1168e11ed85 https://hg.mozilla.org/integration/autoland/rev/5fe5a185035e Text Fragments: Ensure context terms don't start/end with whitespace when reaching maximum length. r=smaug
Status: ASSIGNED → RESOLVED
Closed: 6 months ago
Resolution: --- → FIXED
Target Milestone: --- → 145 Branch
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: