Closed Bug 1684365 Opened 3 years ago Closed 3 years ago

Firefox 84.0.1 crashes in Wayland mode

Categories

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

Firefox 84
defect

Tracking

()

RESOLVED FIXED
87 Branch
Tracking Status
firefox87 --- fixed

People

(Reporter: mh, Assigned: mh)

References

(Blocks 1 open bug)

Details

Attachments

(2 files)

User Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Firefox/78.0

Steps to reproduce:

I compiled and installed Firefox 48.0.1 under Gentoo Linux.

Actual results:

Firefox works in X11 mode, but it crashes in Wayland mode with SIGSEGV.

I traced down the error to: firefox-84.0.1/toolkit/components/remote/nsRemoteService.cpp:172

For a backtrace and details: See https://bugs.gentoo.org/762035

Expected results:

An error check is missing before line 172. The error check should make sure that initialization succeeded. It should abort gently with an error message if initialization failed.

Below is the function. I marked line 172 and the position of the missing error check.

void nsRemoteService::StartupServer() {
if (mRemoteServer) {
return;
}

if (mProfile.IsEmpty()) {
return;
}

#ifdef MOZ_WIDGET_GTK
bool useX11Remote = GDK_IS_X11_DISPLAY(gdk_display_get_default());

if defined(MOZ_ENABLE_DBUS)

if (!useX11Remote || getenv(DBUS_REMOTE_ENV)) {
mRemoteServer = MakeUnique<nsDBusRemoteServer>();
}

endif

if (!mRemoteServer && useX11Remote) {
mRemoteServer = MakeUnique<nsGTKRemoteServer>();
}
#elif defined(XP_WIN)
mRemoteServer = MakeUnique<nsWinRemoteServer>();
#elif defined(XP_DARWIN)
mRemoteServer = MakeUnique<nsMacRemoteServer>();
#else
return;
#endif

// MISSING ERROR CHECK BEFORE line 172

nsresult rv = mRemoteServer->Startup(mProgram.get(), mProfile.get());

if (NS_FAILED(rv)) {
mRemoteServer = nullptr;
return;
}

nsCOMPtr<nsIObserverService> obs(
do_GetService("@mozilla.org/observer-service;1"));
if (obs) {
obs->AddObserver(this, "xpcom-shutdown", false);
obs->AddObserver(this, "quit-application", false);
}
}

The bold lines in the function above were not intended. I just copied the source code - and Bugzilla decided to print some of the ifdef macros in bold typeface.

Bugbug thinks this bug should belong to this component, but please revert this change in case of error.

Component: Untriaged → Widget: Gtk
Product: Firefox → Core

Michael, do you mind to create a patch for it?
Thanks.

Blocks: wayland
Flags: needinfo?(mh)
Priority: -- → P3

Patch for missing NULL pointer check

Flags: needinfo?(mh)

I can't reproduce the crash in Wayland mode on Firefox 84.0.2 nor on the latest Nightly 86.0a1- tried on Ubuntu 20.04 x64 machine since I do not have Gentoo Linux.

Simona, if you want to reproduce the crash: compile Firefox with Wayland support AND disable dbus:
--enable-default-toolkit=cairo-gtk3-wayland
--disable-dbus
Start Firefox in Wayland mode:
MOZ_ENABLE_WAYLAND="1" firefox

Thanks Michael. To land this patch we'd need to go through Phabricator, see https://moz-conduit.readthedocs.io/en/latest/phabricator-user.html for details. Do you mind to take that path?
Thanks.

Flags: needinfo?(mh)

Firefox 84.0.1 crashes under Gentoo Linux if it is started in
Wayland mode and if it was compiled WITH Wayland support and
WITHOUT dbus support.

I traced down the problem to line 172 of
toolkit/components/remote/nsRemoteService.cpp:

nsresult rv = mRemoteServer->Startup(mProgram.get(), mProfile.get());

mRemoteServer is NULL and Firefox crashes.

This patch adds a NULL pointer check before that line.

See:

I added the patch to Phabricator (see previous comment)...

Flags: needinfo?(mh)
Assignee: nobody → mh

Updated, Thanks.

Pushed by stransky@redhat.com:
https://hg.mozilla.org/integration/autoland/rev/1edc48b99c80
Add a null pointer check so that Firefox won't crash when it can't initialize mRemoteServer r=stransky
Status: UNCONFIRMED → RESOLVED
Closed: 3 years ago
Resolution: --- → FIXED
Target Milestone: --- → 87 Branch

can we get a backport of the fix to firefox beta 86 branch?

Flags: needinfo?(stransky)

Ehm, do you really run ESR line under Wayland but without DBus? I wonder what's use case for it.

Flags: needinfo?(stransky)
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: