Closed Bug 1824697 Opened 2 years ago Closed 3 months ago

Crash in [@ nsObserverService::EnsureValidCall | nsObserverService::RemoveObserver | LocalesChangedObserver::Unregister]

Categories

(Core :: Widget: Win32, defect, P3)

Unspecified
Windows
defect

Tracking

()

RESOLVED FIXED
139 Branch
Tracking Status
firefox-esr115 --- wontfix
firefox-esr128 --- wontfix
firefox137 --- wontfix
firefox138 --- fixed
firefox139 --- fixed

People

(Reporter: gsvelto, Assigned: gstoll)

Details

(Keywords: crash, topcrash, Whiteboard: [win:stability])

Crash Data

Attachments

(2 files)

Crash report: https://crash-stats.mozilla.org/report/index/dd505b68-cee2-4698-b3be-26bbc0230327

MOZ_CRASH Reason: MOZ_CRASH(Using observer service off the main thread!)

Top 10 frames of crashing thread:

0  xul.dll  nsObserverService::EnsureValidCall const  xpcom/ds/nsObserverService.cpp:171
0  xul.dll  nsObserverService::RemoveObserver  xpcom/ds/nsObserverService.cpp:230
1  xul.dll  LocalesChangedObserver::Unregister  widget/nsBaseWidget.cpp:289
1  xul.dll  nsBaseWidget::FreeLocalesChangedObserver  widget/nsBaseWidget.cpp:381
1  xul.dll  nsBaseWidget::~nsBaseWidget  widget/nsBaseWidget.cpp:400
2  xul.dll  nsWindow::~nsWindow  widget/windows/nsWindow.cpp:782
3  xul.dll  nsBaseWidget::Release  widget/nsBaseWidget.cpp:130
3  xul.dll  mozilla::RefPtrTraits<nsWindow>::Release  mfbt/RefPtr.h:50
3  xul.dll  RefPtr<nsWindow>::ConstRemovingRefPtrTraits<nsWindow>::Release  mfbt/RefPtr.h:381
3  xul.dll  RefPtr<nsWindow>::~RefPtr  mfbt/RefPtr.h:81

It seems we're destroying a window off the main thread and the cascade of operations is trying to unregister an observer which can only be done in the main thread. I'm not 100% sure who's at fault here so I'm putting this in the widget component for now. This crash signature was probably hidden in bug 1276919.

Added a signature for older Firefox versions.

Crash Signature: [@ nsObserverService::EnsureValidCall | nsObserverService::RemoveObserver | LocalesChangedObserver::Unregister] → [@ nsObserverService::EnsureValidCall | nsObserverService::RemoveObserver | LocalesChangedObserver::Unregister] [@ nsObserverService::RemoveObserver | nsBaseWidget::~nsBaseWidget]
Severity: -- → S3
Component: Widget → Widget: Win32
Priority: -- → P3
Whiteboard: [win:stability]

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

  • Top 20 desktop browser crashes on beta

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

For more information, please visit BugBot documentation.

Flags: needinfo?(davidp99)
Keywords: topcrash
Assignee: nobody → gstoll
Status: NEW → ASSIGNED

It looks like UpdateWorkspaceIdTask (which runs on a background thread) is holding on to a RefPtr<nsWindow>, which means if it's the last reference to that nsWindow it will release it on the background thread, leading to this crash. I think making the task just use a WeakPtr instead should address this.

Flags: needinfo?(davidp99)

We avoid this by only holding on to a WeakPtr of the nsWindow so that
the UpdateWorkspaceIdTask will never hold the last reference to the
nsWindow, so it should never Release() it.

Pushed by gstoll@mozilla.com: https://hg.mozilla.org/integration/autoland/rev/4a490233c3d0 do not release nsWindow on a background thread r=win-reviewers,handyman
Status: ASSIGNED → RESOLVED
Closed: 3 months ago
Resolution: --- → FIXED
Target Milestone: --- → 139 Branch

:gstoll did you want to uplift this to 138beta?

Flags: needinfo?(gstoll)

Yeah, I think this is worth doing. Thanks!

Flags: needinfo?(gstoll)

We avoid this by only holding on to a WeakPtr of the nsWindow so that
the UpdateWorkspaceIdTask will never hold the last reference to the
nsWindow, so it should never Release() it.

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

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

beta Uplift Approval Request

  • User impact if declined: users continue to hit a topcrash
  • Code covered by automated testing: no
  • Fix verified in Nightly: no
  • Needs manual QE test: no
  • Steps to reproduce for manual QE testing: n/a
  • Risk associated with taking this patch: low
  • Explanation of risk level: Just taking a weak reference instead of a strong reference. I think it is more likely that this doesn't fix the crash (since we don't have STR), but it should be safe
  • String changes made/needed: no
  • Is Android affected?: no
Attachment #9477466 - Flags: approval-mozilla-beta? → approval-mozilla-beta+

Looks like these crashes have indeed gone away in 138 🎉

You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: