Closed Bug 2093691 Opened 6 days ago Closed 4 days ago

Assertion failure: false (MOZ_ASSERT_UNREACHABLE: bad offset in transformed textrun), at checkouts/gecko/layout/generic/nsTextRunTransformations.cpp:159

Categories

(Core :: Layout: Text and Fonts, defect)

defect

Tracking

()

VERIFIED FIXED
162 Branch
Tracking Status
firefox-esr115 --- wontfix
firefox-esr153 --- wontfix
firefox160 --- unaffected
firefox161 --- wontfix
firefox162 --- verified

People

(Reporter: tsmith, Assigned: jfkthame)

References

(Blocks 1 open bug)

Details

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

Attachments

(1 file, 1 external file)

Attached file testcase.html —

Found while fuzzing m-c 20261113-a05145e48701 (--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: false (MOZ_ASSERT_UNREACHABLE: bad offset in transformed textrun), at checkouts/gecko/layout/generic/nsTextRunTransformations.cpp:159

#0 0x7fffeb4e4c0e in MOZ_CrashSequence /builds/worker/workspace/obj-build/dist/include/mozilla/Assertions.h:261:3
#1 0x7fffeb4e4c0e in MergeCharactersInTextRun(gfxTextRun*, gfxTextRun*, bool const*, bool const*) /builds/worker/workspace/obj-build/layout/generic/./../../../../checkouts/gecko/layout/generic/nsTextRunTransformations.cpp:159:7
#2 0x7fffeb4e6c8f in nsCaseTransformTextRunFactory::RebuildTextRun(nsTransformedTextRun*, mozilla::gfx::DrawTarget*, gfxMissingFontRecorder*) /builds/worker/workspace/obj-build/layout/generic/./../../../../checkouts/gecko/layout/generic/nsTextRunTransformations.cpp:968:5
#3 0x7fffeb4b7403 in FinishSettingProperties /builds/worker/workspace/obj-build/layout/generic/./../../../../checkouts/gecko/layout/generic/nsTextRunTransformations.h:173:17
#4 0x7fffeb4b7403 in Finish /builds/worker/workspace/obj-build/layout/generic/./../../../../checkouts/gecko/layout/generic/nsTextFrame.cpp:1255:29
#5 0x7fffeb4b7403 in BuildTextRunsScanner::FlushLineBreaks(gfxTextRun*) /builds/worker/workspace/obj-build/layout/generic/./../../../../checkouts/gecko/layout/generic/nsTextFrame.cpp:1871:21
#6 0x7fffeb4b4660 in BuildTextRunsScanner::FlushFrames(bool, bool) /builds/worker/workspace/obj-build/layout/generic/./../../../../checkouts/gecko/layout/generic/nsTextFrame.cpp:1846:5
#7 0x7fffeb4bbaa6 in BuildTextRuns /builds/worker/workspace/obj-build/layout/generic/./../../../../checkouts/gecko/layout/generic/nsTextFrame.cpp:1745:11
#8 0x7fffeb4bbaa6 in nsTextFrame::EnsureTextRun(nsTextFrame::TextRunType, mozilla::gfx::DrawTarget*, nsIFrame*, GenericLineListIterator<nsLineLink, false> const*, unsigned int*) /builds/worker/workspace/obj-build/layout/generic/./../../../../checkouts/gecko/layout/generic/nsTextFrame.cpp:3239:7
#9 0x7fffeb4de163 in nsTextFrame::ReflowText(nsLineLayout&, int, mozilla::gfx::DrawTarget*, mozilla::ReflowOutput&, nsReflowStatus&) /builds/worker/workspace/obj-build/layout/generic/./../../../../checkouts/gecko/layout/generic/nsTextFrame.cpp:11103:7
#10 0x7fffeb487024 in nsLineLayout::ReflowFrame(nsIFrame*, nsReflowStatus&, mozilla::ReflowOutput*, bool&) /builds/worker/workspace/obj-build/layout/generic/./../../../../checkouts/gecko/layout/generic/nsLineLayout.cpp:866:40
#11 0x7fffeb39f58f in nsBlockFrame::ReflowInlineFrame(mozilla::BlockReflowState&, nsLineLayout&, GenericLineListIterator<nsLineLink, false>, nsIFrame*, LineReflowStatus*) /builds/worker/workspace/obj-build/layout/generic/./../../../../checkouts/gecko/layout/generic/nsBlockFrame.cpp:6009:15
#12 0x7fffeb39e48a in nsBlockFrame::DoReflowInlineFrames(mozilla::BlockReflowState&, nsLineLayout&, GenericLineListIterator<nsLineLink, false>, nsFlowAreaRect&, int&, nsFloatManager::SavedState*, bool*, LineReflowStatus*, bool) /builds/worker/workspace/obj-build/layout/generic/./../../../../checkouts/gecko/layout/generic/nsBlockFrame.cpp:5808:5
#13 0x7fffeb399e38 in nsBlockFrame::ReflowInlineFrames(mozilla::BlockReflowState&, GenericLineListIterator<nsLineLink, false>, bool*) /builds/worker/workspace/obj-build/layout/generic/./../../../../checkouts/gecko/layout/generic/nsBlockFrame.cpp:5665:9
#14 0x7fffeb395890 in nsBlockFrame::ReflowLine(mozilla::BlockReflowState&, GenericLineListIterator<nsLineLink, false>, bool*) /builds/worker/workspace/obj-build/layout/generic/./../../../../checkouts/gecko/layout/generic/nsBlockFrame.cpp:4553:24
#15 0x7fffeb38e101 in nsBlockFrame::ReflowDirtyLines(mozilla::BlockReflowState&) /builds/worker/workspace/obj-build/layout/generic/./../../../../checkouts/gecko/layout/generic/nsBlockFrame.cpp:4048:29
#16 0x7fffeb38a270 in nsBlockFrame::TrialReflow(nsPresContext*, mozilla::ReflowOutput&, mozilla::ReflowInput const&, nsBlockFrame::TrialReflowState&) /builds/worker/workspace/obj-build/layout/generic/./../../../../checkouts/gecko/layout/generic/nsBlockFrame.cpp:2460:35
#17 0x7fffeb3887ef in nsBlockFrame::Reflow(nsPresContext*, mozilla::ReflowOutput&, mozilla::ReflowInput const&, nsReflowStatus&) /builds/worker/workspace/obj-build/layout/generic/./../../../../checkouts/gecko/layout/generic/nsBlockFrame.cpp:2017:9
#18 0x7fffeb3be544 in nsContainerFrame::ReflowChild(nsIFrame*, nsPresContext*, mozilla::ReflowOutput&, mozilla::ReflowInput const&, mozilla::WritingMode const&, mozilla::LogicalPoint const&, nsSize const&, nsIFrame::ReflowChildFlags, nsReflowStatus&, nsOverflowContinuationTracker*) /builds/worker/workspace/obj-build/layout/generic/./../../../../checkouts/gecko/layout/generic/nsContainerFrame.cpp:757:14
#19 0x7fffeb3ae5ba in nsCanvasFrame::Reflow(nsPresContext*, mozilla::ReflowOutput&, mozilla::ReflowInput const&, nsReflowStatus&) /builds/worker/workspace/obj-build/layout/generic/./../../../../checkouts/gecko/layout/generic/nsCanvasFrame.cpp:513:7
#20 0x7fffeb3be544 in nsContainerFrame::ReflowChild(nsIFrame*, nsPresContext*, mozilla::ReflowOutput&, mozilla::ReflowInput const&, mozilla::WritingMode const&, mozilla::LogicalPoint const&, nsSize const&, nsIFrame::ReflowChildFlags, nsReflowStatus&, nsOverflowContinuationTracker*) /builds/worker/workspace/obj-build/layout/generic/./../../../../checkouts/gecko/layout/generic/nsContainerFrame.cpp:757:14
#21 0x7fffeb353be8 in mozilla::ScrollContainerFrame::ReflowScrolledFrame(mozilla::ScrollReflowInput&, bool, bool, mozilla::ReflowOutput*) /builds/worker/workspace/obj-build/layout/generic/./../../../../checkouts/gecko/layout/generic/ScrollContainerFrame.cpp:978:3
#22 0x7fffeb3543e3 in mozilla::ScrollContainerFrame::ReflowContents(mozilla::ScrollReflowInput&, mozilla::ReflowOutput const&) /builds/worker/workspace/obj-build/layout/generic/./../../../../checkouts/gecko/layout/generic/ScrollContainerFrame.cpp:1088:3
#23 0x7fffeb35659e in mozilla::ScrollContainerFrame::Reflow(nsPresContext*, mozilla::ReflowOutput&, mozilla::ReflowInput const&, nsReflowStatus&) /builds/worker/workspace/obj-build/layout/generic/./../../../../checkouts/gecko/layout/generic/ScrollContainerFrame.cpp:1541:3
#24 0x7fffeb3c9276 in nsContainerFrame::ReflowChild(nsIFrame*, nsPresContext*, mozilla::ReflowOutput&, mozilla::ReflowInput const&, int, int, nsIFrame::ReflowChildFlags, nsReflowStatus&, nsOverflowContinuationTracker*) /builds/worker/workspace/obj-build/layout/generic/./../../../../checkouts/gecko/layout/generic/nsContainerFrame.cpp:793:14
#25 0x7fffeb380fc6 in mozilla::ViewportFrame::Reflow(nsPresContext*, mozilla::ReflowOutput&, mozilla::ReflowInput const&, nsReflowStatus&) /builds/worker/workspace/obj-build/layout/generic/./../../../../checkouts/gecko/layout/generic/ViewportFrame.cpp:453:7
#26 0x7fffeb2534c4 in mozilla::PresShell::DoReflow(nsIFrame*, bool, mozilla::OverflowChangedTracker*) /builds/worker/workspace/obj-build/layout/base/./../../../../checkouts/gecko/layout/base/PresShell.cpp:10879:11
#27 0x7fffeb278ef1 in mozilla::PresShell::ProcessReflowCommands(bool) /builds/worker/workspace/obj-build/layout/base/./../../../../checkouts/gecko/layout/base/PresShell.cpp:11009:22
#28 0x7fffeb25d16a in DoFlushLayout /builds/worker/workspace/obj-build/layout/base/./../../../../checkouts/gecko/layout/base/PresShell.cpp:11051:10
#29 0x7fffeb25d16a in mozilla::PresShell::DoFlushPendingNotifications(mozilla::ChangesToFlush) /builds/worker/workspace/obj-build/layout/base/./../../../../checkouts/gecko/layout/base/PresShell.cpp:4693:9
#30 0x7fffe6f5b957 in FlushPendingNotifications /builds/worker/workspace/obj-build/dist/include/mozilla/PresShell.h:1567:5
#31 0x7fffe6f5b957 in mozilla::dom::Document::DetermineProximityToViewportAndNotifyResizeObservers() /builds/worker/workspace/obj-build/dom/base/./../../../../checkouts/gecko/dom/base/Document.cpp:20121:11
#32 0x7fffeb21f094 in operator() /builds/worker/checkouts/gecko/layout/base/nsRefreshDriver.cpp:2544:14
#33 0x7fffeb21f094 in operator() /builds/worker/checkouts/gecko/layout/base/nsRefreshDriver.cpp:1317:7
#34 0x7fffeb21f094 in RunRenderingPhaseLegacy<(lambda at /builds/worker/checkouts/gecko/layout/base/nsRefreshDriver.cpp:1296:35)> /builds/worker/checkouts/gecko/layout/base/nsRefreshDriver.cpp:1289:3
#35 0x7fffeb21f094 in void nsRefreshDriver::RunRenderingPhase<nsRefreshDriver::Tick(mozilla::layers::BaseTransactionId<mozilla::VsyncIdType>, mozilla::TimeStamp, nsRefreshDriver::IsExtraTick)::$_11>(mozilla::RenderingPhase, nsRefreshDriver::Tick(mozilla::layers::BaseTransactionId<mozilla::VsyncIdType>, mozilla::TimeStamp, nsRefreshDriver::IsExtraTick)::$_11&&, bool (*)(mozilla::dom::Document const&)) /builds/worker/checkouts/gecko/layout/base/nsRefreshDriver.cpp:1296:3
#36 0x7fffeb219d9c in nsRefreshDriver::Tick(mozilla::layers::BaseTransactionId<mozilla::VsyncIdType>, mozilla::TimeStamp, nsRefreshDriver::IsExtraTick) /builds/worker/checkouts/gecko/layout/base/nsRefreshDriver.cpp:2540:3
#37 0x7fffeb226d1f in operator() /builds/worker/checkouts/gecko/layout/base/nsRefreshDriver.cpp:1826:25
#38 0x7fffeb226d1f in mozilla::detail::RunnableFunction<nsRefreshDriver::EnsureTimerStarted(nsRefreshDriver::EnsureTimerStartedFlags)::$_1>::Run() /builds/worker/workspace/obj-build/dist/include/nsThreadUtils.h:535:5
#39 0x7fffe57804c7 in mozilla::RunnableTask::Run() /builds/worker/workspace/obj-build/xpcom/threads/./../../../../checkouts/gecko/xpcom/threads/TaskController.cpp:756:16
#40 0x7fffe5775215 in mozilla::TaskController::DoExecuteNextTaskOnlyMainThreadInternal(mozilla::detail::BaseAutoLock<mozilla::Mutex&> const&) /builds/worker/workspace/obj-build/xpcom/threads/./../../../../checkouts/gecko/xpcom/threads/TaskController.cpp:1401:20
#41 0x7fffe5773d17 in mozilla::TaskController::ExecuteNextTaskOnlyMainThreadInternal(mozilla::detail::BaseAutoLock<mozilla::Mutex&> const&) /builds/worker/workspace/obj-build/xpcom/threads/./../../../../checkouts/gecko/xpcom/threads/TaskController.cpp:1221:15
#42 0x7fffe5774185 in mozilla::TaskController::ProcessPendingMTTask(bool) /builds/worker/workspace/obj-build/xpcom/threads/./../../../../checkouts/gecko/xpcom/threads/TaskController.cpp:692:36
#43 0x7fffe577fb06 in operator() /builds/worker/workspace/obj-build/xpcom/threads/./../../../../checkouts/gecko/xpcom/threads/TaskController.cpp:380:37
#44 0x7fffe577fb06 in mozilla::detail::RunnableFunction<mozilla::TaskController::TaskController()::$_0>::Run() /builds/worker/checkouts/gecko/xpcom/threads/nsThreadUtils.h:535:5
#45 0x7fffe5795403 in nsThread::ProcessNextEvent(bool, bool*) /builds/worker/workspace/obj-build/xpcom/threads/./../../../../checkouts/gecko/xpcom/threads/nsThread.cpp:1319:16
#46 0x7fffe579ad7f in NS_ProcessNextEvent(nsIThread*, bool) /builds/worker/workspace/obj-build/xpcom/threads/./../../../../checkouts/gecko/xpcom/threads/nsThreadUtils.cpp:471:32
#47 0x7fffe58b5855 in mozilla::ipc::MessagePump::Run(base::MessagePump::Delegate*) /builds/worker/workspace/obj-build/ipc/glue/./../../../../checkouts/gecko/ipc/glue/MessagePump.cpp:83:21
#48 0x7fffe5810ca1 in RunHandler /builds/worker/workspace/obj-build/ipc/chromium/./../../../../checkouts/gecko/ipc/chromium/src/base/message_loop.cc:371:3
#49 0x7fffe5810ca1 in MessageLoop::Run() /builds/worker/workspace/obj-build/ipc/chromium/./../../../../checkouts/gecko/ipc/chromium/src/base/message_loop.cc:353:3
#50 0x7fffeadcb808 in nsBaseAppShell::Run() /builds/worker/workspace/obj-build/widget/./../../../checkouts/gecko/widget/nsBaseAppShell.cpp:151:27
#51 0x7fffeaeb0f74 in nsAppShell::Run() /builds/worker/workspace/obj-build/widget/gtk/./../../../../checkouts/gecko/widget/gtk/nsAppShell.cpp:581:33
#52 0x7fffebfa7d8b in XRE_RunAppShell() /builds/worker/checkouts/gecko/toolkit/xre/nsEmbedFunctions.cpp:636:20
#53 0x7fffe58b6704 in mozilla::ipc::MessagePumpForChildProcess::Run(base::MessagePump::Delegate*) /builds/worker/workspace/obj-build/ipc/glue/./../../../../checkouts/gecko/ipc/glue/MessagePump.cpp:233:19
#54 0x7fffe5810ca1 in RunHandler /builds/worker/workspace/obj-build/ipc/chromium/./../../../../checkouts/gecko/ipc/chromium/src/base/message_loop.cc:371:3
#55 0x7fffe5810ca1 in MessageLoop::Run() /builds/worker/workspace/obj-build/ipc/chromium/./../../../../checkouts/gecko/ipc/chromium/src/base/message_loop.cc:353:3
#56 0x7fffebfa7224 in XRE_InitChildProcess(int, char**, XREChildData const*) /builds/worker/checkouts/gecko/toolkit/xre/nsEmbedFunctions.cpp:574:34
#57 0x5555555dc07c in main /builds/worker/checkouts/gecko/browser/app/nsBrowserApp.cpp:469:22
Flags: in-testsuite?

This is a new assertion that jfkthame added quite recently.

Jonathan, could you take a look?

(It looks to me like we handle the bad offset gracefully -- skipping the body of the loop rather than proceeding with the bad offset -- so I'm tentatively triaging as S3, but please adjust if you see fit. And either way, given that fuzzing was able to trigger this assertion within a few days of the assertion being added, we might want to reconsider this assertion and/or fix whatever's making us trip it, or else fuzzers might start hitting it a lot...)

Severity: -- → S3
Flags: needinfo?(jfkthame)

Searchfox link to the assertion in question, for convenience:
https://searchfox.org/firefox-main/rev/d7161e35da7704cff60e48ee86fb7747ffcc93c7/layout/generic/nsTextRunTransformations.cpp#155-161

for (gfxTextRun::GlyphRunIterator iter(aSrc, gfxTextRun::Range(aSrc));
     !iter.AtEnd(); iter.NextRun()) {
  const gfxTextRun::GlyphRun* run = iter.GlyphRun();
  if (offset >= aDest->GetLength()) {
    MOZ_ASSERT_UNREACHABLE("bad offset in transformed textrun");
    break;
  }

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

Start: d1b813e0d2387b5e453e10f4be3b88523c447d15 (20261109214446)
End: 57a6ef267e57891d8ddaeac32a3dd31ac2900679 (20261110035552)
Pushlog: https://hg.mozilla.org/mozilla-central/pushloghtml?fromchange=d1b813e0d2387b5e453e10f4be3b88523c447d15&tochange=57a6ef267e57891d8ddaeac32a3dd31ac2900679

Successfully recorded a pernosco session. A link to the pernosco session will be added here shortly.

Whiteboard: [bugmon:bisected,confirmed]

A pernosco session for this bug can be found here.

The pernosco run shows that, in the code quoted in comment 2, we've got offset and aDest->GetLength() both having value 1. That satisfies the >= comparison, so we hit the MOZ_ASSERT_UNREACHABLE expression.

Yeah, it turns out the assertion is a bit too eager; it's possible to (safely) arrive here with offset = destLength if there was a font change in the middle of an expanded mapping (like ß -> Ss). The font change in this case happens because of a further bug, which is that the fullwidth transform doesn't get applied to the first character of the expanded mapping, only to the second. I'll file that as a separate bug.

Flags: needinfo?(jfkthame)
Assignee: nobody → jfkthame
Status: NEW → ASSIGNED
See Also: → 2094563
Pushed by jkew@mozilla.com: https://github.com/mozilla-firefox/firefox/commit/14972f05a5c8 https://hg.mozilla.org/integration/autoland/rev/e7c34e072d10 Don't assert in MergeCharactersInTextRun when a font change leaves only discarded continuation characters. r=layout-reviewers,jwatt
Status: ASSIGNED → RESOLVED
Closed: 4 days ago
Resolution: --- → FIXED
Target Milestone: --- → 162 Branch

The patch landed in nightly and beta is affected, along with ESR.

:jfkthame, please make an uplift decision for beta and ESR:

  • For beta, nominate the patch for beta uplift approval if the fix should be included in this release, or set status-firefox161 to wontfix if the fix can wait for the next release.
  • For ESR, nominate the patch for the appropriate ESR uplift approval if the fix should be included in ESR, or set the ESR status flag(s) to wontfix if an uplift isn't needed. Each affected ESR release needs a decision.

Uplift requests can be submitted from Lando: D343885.

See Requesting an Uplift for documentation on how to request an uplift.

For more information, please visit BugBot documentation.

Flags: needinfo?(jfkthame)

Thanks for the fix, Jonathan!

RE uplift consideration: there's no urgency, since this has zero user-impact; it's just a change to debug-only code (swapping a MOZ_ASSERT_UNREACHABLE for a MOZ_ASSERT, both of which are debug-only). Nonetheless, it might still be worth uplifting, because it's zero-risk and it would keep this (recently-introduced) code more consistent between branches, which avoids hassle if/when we need to uplift any other future patches in this area of code.

Created web-platform-tests PR https://github.com/web-platform-tests/wpt/pull/65383 for changes under testing/web-platform/tests

Whiteboard: [bugmon:bisected,confirmed] → [bugmon:bisected,confirmed], [wptsync upstream]

Upstream PR merged by moz-wptsync-bot

Flags: needinfo?(jfkthame)
Flags: in-testsuite?
Flags: in-testsuite+

Verified bug as fixed on rev mozilla-central 20261118160613-b33514fa2c0a.
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: