Closed Bug 2093306 Opened 11 days ago Closed 9 days ago

Crash in [@ mozilla::Maybe<T>::operator* | mozilla::TouchSwipeState::GetDelta]

Categories

(Core :: Panning and Zooming, defect)

defect

Tracking

()

RESOLVED FIXED
162 Branch
Tracking Status
firefox-esr153 --- unaffected
firefox160 --- unaffected
firefox161 --- unaffected
firefox162 --- fixed

People

(Reporter: clouseau-bot, Assigned: canalun)

References

(Blocks 2 open bugs, Regression)

Details

(Keywords: crash, regression)

Crash Data

Attachments

(1 external file, 1 obsolete file)

Crash report: https://crash-stats.mozilla.org/report/index/f55ec5d5-9b88-45d2-821a-037160261116

MOZ_CRASH Reason:

MOZ_RELEASE_ASSERT(isSome())

Top 10 frames:

0  xul.dll  nsIWidget::MayStartSwipeForTouchInput(mozilla::MultiTouchInput const&, mozilla::...  widget/nsIWidget.cpp:1367
1  xul.dll  nsIWidget::ReceiveTouchSwipableDirections(unsigned long long, mozilla::SideBits)  widget/nsIWidget.cpp:1505
2  xul.dll  mozilla::detail::RunnableMethodImpl<nsCOMPtr<nsIWidget>,void (nsIWidget::*)(unsi...  xpcom/threads/nsThreadUtils.h:1124
3  xul.dll  mozilla::TaskController::DoExecuteNextTaskOnlyMainThreadInternal(mozilla::detail...  xpcom/threads/TaskController.cpp:1401
4  xul.dll  NS_ProcessNextEvent(nsIThread*, bool)  xpcom/threads/nsThreadUtils.cpp:471
5  xul.dll  mozilla::ipc::MessagePump::Run(base::MessagePump::Delegate*)  ipc/glue/MessagePump.cpp:83
6  xul.dll  MessageLoop::RunHandler()  ipc/chromium/src/base/message_loop.cc:371
7  xul.dll  nsAppShell::Run()  widget/windows/nsAppShell.cpp:632
8  xul.dll  nsAppStartup::Run()  toolkit/components/startup/nsAppStartup.cpp:308
9  xul.dll  XREMain::XRE_mainRun()  toolkit/xre/nsAppRunner.cpp:6771

There is 1 crash in nightly 162 with buildid 20261115213519.

Crash-stats has no report of this signature on any earlier build, and Socorro's all-time signature index has no entry for it yet — as far as we can tell it is new with this build.

Clouseau analysis (automated, 72% worth investigating — a calibrated estimate that this is worth someone's time, not that the changeset below caused it). The mechanism below fits the evidence but is not proven end-to-end:

TouchSwipeState::GetDelta probably dereferences an empty previousTouchPoint in nsIWidget::MayStartSwipeForTouchInput (nsIWidget.cpp:1367) when a queued touchmove is replayed after an earlier queued touchend reset the swipe state.

  1. 7a86a3cd2ed4 added nsIWidget::ReceiveTouchSwipableDirections, which calls Start() and then replays every queued input through HandleTouchInputForSwipe without checking the phase.
  2. On Windows a single WM_TOUCH can deliver MULTITOUCH_START for a new finger and then MULTITOUCH_END for a lifted one, as the bug 2088553 comment in DispatchTouchInput documents. If this happens while WaitingForAPZ, the 1-touch START calls Reset() and may start a new wait, and the END and later moves are queued.
  3. During replay, TouchCounter::Update drops the count to 0 on the queued END, and MayStartSwipeForTouchInput calls TouchSwipeState::Reset(), leaving previousTouchPoint as Nothing and phase as Idle.
  4. The next queued MOVE (finger still down) reaches MayStartSwipeForTouchInput in Idle. Its result carries the default Some(SideBits::eNone), so the branch at line 1352 is skipped and GetDelta dereferences Nothing.

The frames fit this chain: frame 1 is the replay call at nsIWidget.cpp:1505 and frame 0 the GetDelta dereference at 1367, not the other dereference at 1356. The live path already ignores non-START input in Idle through ignoreForSwipe (bug 2088553), but the replay loop has no equivalent. The exact input sequence (END followed by MOVE in the queue) is inferred from the code and cannot be seen in this single report.

The crash is on a frame that 7a86a3cd2ed4 wrote: frame 1 at nsIWidget.cpp:1505 blames to 7a86a3cd2ed4 (landed 2026-11-13). The first and only report is from build 20261115213519, two days later, and the signature has no earlier history. The report is from Windows 11 in the parent process, matching the Windows-only touchscreen swipe path, with no bit-flip annotation and no Raptor Lake CPU. The other bug 2085128 parts were checked. ab5eaf433784's re-queue fires only in WaitingForAPZ, so it is not on the crashing path after a reset. 47803bb27822 adds another way into WaitingForAPZ, which widens exposure. 07487bac6f80 is a refactor that split out HandleTouchInputForSwipe.

Suspected regressor: 7a86a3cd2ed4 (gh) (bug 2085128) by :canalun.

Impact

The parent process crashes, so the whole browser closes. Only the MOZ_ASSERTs in MayStartSwipeForTouchInput and GetDelta are debug-only. The Maybe::operator* dereference is a MOZ_RELEASE_ASSERT, so every build crashes at line 1367.

Possible fixes

  • In the ReceiveTouchSwipableDirections replay loop, apply the same rule as the live path's ignoreForSwipe: once the phase is back to Idle, skip queued non-START inputs (or stop replaying the rest of the queue).
  • Make MayStartSwipeForTouchInput return early for MULTITOUCH_MOVE when the phase is Idle or previousTouchPoint is Nothing, instead of relying on the debug-only MOZ_ASSERT at line 1325.
  • Possibly revisit the Reset() on a 1-touch MULTITOUCH_START while WaitingForAPZ, since the Windows START-then-END ordering (bug 2089005) leaves a lifted-finger END behind it in the queue.

How to confirm

Extend browser_test_touchscreen_swipe_gesture_while_waiting.js: keep content busy so the target is unconfirmed, then dispatch START(finger A), START(finger B only), END(finger A), MOVE(finger B) via nsIWidget::DispatchTouchInput, and let the swipable directions arrive. A debug build should hit the MOZ_ASSERT at line 1325 in MayStartSwipeForTouchInput, and an opt build should crash at line 1367.

Code references:

What the automated skeptic pass checked

In its own words (a pass means the check succeeded, which is not always support for the conclusion):

  • unverifiable step4 — The END-then-MOVE queue needs the Windows START(new finger)-then-END(lifted finger) ordering while WaitingForAPZ, and APZ returning Nothing for the new START so the widget waits again. Both are plausible from the code (bug 2088553 comment, TouchCounter::Update on START sets count = mTouches.Length()), but neither is visible in the crash report.
  • unverifiable alt_47803bb27822 — Adds a second way into WaitingForAPZ (Pending to WaitingForAPZ on the first move). It widens exposure to the same replay hole but is not a separate cause.
  • pass step1 — TouchSwipeState::Reset() is *this = TouchSwipeState{}. The default previousTouchPoint is Nothing and the default phase is Idle. GetDelta only has a debug MOZ_ASSERT before *previousTouchPoint.
  • pass edge0 — The replay loop at lines 1504-1505 (blamed to 7a86a3cd2ed4) calls HandleTouchInputForSwipe with no Idle guard. The only phase check in the loop is ab5eaf433784's WaitingForAPZ re-queue. Frames 0 and 1 match.
  • pass step3 — A count-0 END resets mid-replay. A queued MOVE keeps Some(eNone), so it crashes at 1367 and not 1356. Nothing in a release build blocks an Idle MOVE apart from the touchpad-swipe check at 1339, which only applies if a touchpad swipe is in progress.
  • pass alt_ab5eaf433784 — The re-queue fires only in WaitingForAPZ. After a mid-replay Reset() the phase is Idle, so it neither causes nor prevents the crash. It only edited the loop.

:canalun, can you have a look please?

Filed automatically by Clouseau with an LLM, from a submitted crash report: not an independent Mozilla discovery

Filed automatically by Clouseau, which analyses nightly crashes with an LLM. Nothing above was written or checked by a human. Please close it as INVALID if it is wrong — that is useful feedback, not a nuisance.

This is not an independent Mozilla discovery: the crash is known here only because somebody submitted the crash report linked at the top. If this duplicates an existing report, please resolve THIS bug as the duplicate and leave the credit with the earlier reporter.

Flags: needinfo?(i.am.kanaru.sato)

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

Flags: needinfo?(i.am.kanaru.sato)
See Also: → 2089005
Blocks: 1443710

:canalun, since you are the author of the regressor, bug 2085128, could you take a look? Also, could you set the severity field?

For more information, please visit BugBot documentation.

Flags: needinfo?(i.am.kanaru.sato)

The crash caused by a Windows widget bug (bug 2089005) can happen when
replaying the queued inputs in ReceiveTouchSwipableDirections() as well.
So the guard is necessary at that time, too.

This patch doesn't include a test case for the same reason explained on
https://phabricator.services.mozilla.com/D339398 .

Assignee: nobody → i.am.kanaru.sato
Status: NEW → ASSIGNED

This patch doesn't change the behavior.

This patch moves the guard for Windows widget bugs into HandleTouchInputForSwipe().
One of the three call sites of that function currently doesn't have the guard. But
that call site works with the guard as well.

Flags: needinfo?(i.am.kanaru.sato)
Attachment #9685251 - Attachment is obsolete: true
Pushed by i.am.kanaru.sato@gmail.com: https://github.com/mozilla-firefox/firefox/commit/1453f834ba40 https://hg.mozilla.org/integration/autoland/rev/2294c38e17be Fix a crash in touchscreen swipe when one finger lifts and another touches down at once while queueing inputs. r=hiro
Status: ASSIGNED → RESOLVED
Closed: 9 days ago
Resolution: --- → FIXED
Target Milestone: --- → 162 Branch
See Also: → 1443710
QA Whiteboard: [qa-triage-done-c163/b162]
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: