Crash in [@ mozilla::widget::WlCompositorCrashHandler]
Categories
(Core :: Widget: Gtk, defect, P3)
Tracking
()
People
(Reporter: mccr8, Assigned: sinker)
References
(Blocks 1 open bug)
Details
(Keywords: crash)
Crash Data
Attachments
(1 external file)
Crash report: https://crash-stats.mozilla.org/report/index/e2114670-8251-4bee-8de9-1650b0241018
MOZ_CRASH Reason:
Compositor crashed (kde) proxy: WP:E WP:CA WP:CR WP:CPCA WP:CPCF
Top 10 frames:
0 libxul.so MOZ_Crash(char const*, int, char const*) mfbt/Assertions.h:317
0 libxul.so mozilla::widget::WlCompositorCrashHandler() widget/gtk/nsWaylandDisplay.cpp:534
1 libxul.so WaylandProxy::CompositorCrashed() third_party/wayland-proxy/wayland-proxy.cpp:996
1 libxul.so ProxiedConnection::ProcessFailure() third_party/wayland-proxy/wayland-proxy.cpp:579
2 libxul.so WaylandProxy::ProcessConnections() third_party/wayland-proxy/wayland-proxy.cpp:842
3 libxul.so WaylandProxy::Run() third_party/wayland-proxy/wayland-proxy.cpp:866
4 libxul.so WaylandProxy::RunProxyThread(WaylandProxy*) third_party/wayland-proxy/wayland-proxy.cpp:892
5 firefox-bin set_alt_signal_stack_and_start(PthreadCreateParams*) mozglue/interposers/pthread_create_interposer.cpp:81
6 libc.so.6 start_thread /usr/src/debug/glibc-2.40/nptl/pthread_create.c:447
7 libc.so.6 __clone3 /usr/src/debug/glibc-2.40/sysdeps/unix/sysv/linux/x86_64/clone3.S:78
| Reporter | ||
Comment 1•2 years ago
|
||
The first instance of this crash I see is in the 20241011104937 Nightly build.
Comment 2•2 years ago
|
||
That's expected, we added this handler specially for this case. It means Wayland compositor crashed so we can't continue. It's not a bug on our side.
Updated•2 years ago
|
Updated•2 years ago
|
Comment 3•2 years ago
|
||
We moved compositor crashes from Bug 1890074 to this one.
Comment 4•1 year ago
|
||
The bug is linked to a topcrash signature, which matches the following criterion:
- Top 10 desktop browser crashes on nightly
For more information, please visit BugBot documentation.
Comment 5•1 year ago
|
||
The crash stat is:
1 Compositor crashed (gnome) proxy: WP:E WP:CA WP:CR WP:CPCA WP:CPCF 56 48.28 %
2 Compositor crashed (hyprland) proxy: WP:E WP:CA WP:CR WP:CPCA WP:CPCF 18 15.52 %
3 Compositor crashed (ubuntu:gnome) proxy: WP:E WP:CA WP:CR WP:CPCA WP:CPCF 16 13.79 %
4 Compositor crashed (kde) proxy: WP:E WP:CA WP:CR WP:CPCA WP:CPCF 13 11.21 %
5 Compositor crashed (niri) proxy: WP:E WP:CA WP:CR WP:CPCA WP:CPCF 4 3.45 %
6 Compositor crashed () proxy: WP:E WP:CA WP:CR WP:CPCA WP:CPCF 3 2.59 %
7 Compositor crashed (kde) proxy: WP:E WP:CA WP:CR WP:CPCF WP:CPSF 2 1.72 %
8 Compositor crashed (labwc:wlroots) proxy: WP:E WP:CA WP:CR WP:CPCA WP:CPCF 2 1.72 %
9 Compositor crashed (ubuntu:gnome) proxy: WP:E WP:CA WP:CR WP:ACT WP:CPCA WP:CPCF 1 0.86 %
10 Compositor crashed (zorin:gnome) proxy: WP:E WP:CA WP:CR WP:CPCA WP:CPCF
WP:E WP:CA WP:CR WP:CPCA WP:CPCF means wayland proxy operates correctly as we expected and the failure is on Wayland compositor side.
Comment 6•1 year ago
|
||
The bug is linked to a topcrash signature, which matches the following criterion:
- Top 10 desktop browser crashes on nightly (startup)
For more information, please visit BugBot documentation.
Comment 7•1 year ago
|
||
Based on the topcrash criteria, the crash signature linked to this bug is not a topcrash signature anymore.
For more information, please visit BugBot documentation.
Comment 8•1 year ago
|
||
This is the current Linux topcrasher.
Comment 9•1 year ago
|
||
(In reply to Martin Stránský [:stransky] (ni? me) from comment #5)
WP:E WP:CA WP:CR WP:CPCA WP:CPCF means wayland proxy operates correctly as we expected and the failure is on Wayland compositor side.
Is this by any means actionable on our side then ?
Comment 10•1 year ago
|
||
No, it's bug on system component which crashes. We can't do anything about it.
Updated•1 year ago
|
Comment 11•1 year ago
|
||
Comment 12•1 year ago
|
||
Comment 13•1 year ago
|
||
Comment 14•1 year ago
|
||
Comment 15•1 year ago
|
||
Comment 16•1 year ago
|
||
Comment 17•1 year ago
|
||
Comment 18•10 months ago
|
||
Note that this is by far the top crasher according to crash pings (whereas crash reports don't show many): https://crash-pings.mozilla.org/#kmsWOu
Comment 22•10 months ago
|
||
Crash ID: 3b279680-c310-4199-8a52-583570260120
Signature: [@ mozilla::widget::WlCompositorCrashHandler ]
Comment 23•10 months ago
|
||
Crash ID: 814ab7cc-29ee-4365-b38c-60a3e0260120
Signature: [@ mozilla::widget::WlCompositorCrashHandler ]
Comment 24•9 months ago
•
|
||
(In reply to Martin Stránský [:stransky] (ni? me) (PTO till Feb 21) from comment #10)
No, it's bug on system component which crashes. We can't do anything about it.
Take this with a grain of AI salt, but there might be something we can do:
Looking at the code, there's no distinction between an actual compositor crash and a normal Wayland session logout/shutdown. Both follow the same path to MOZ_CRASH.
The detection logic is in ProxiedConnection::ProcessFailure() (https://searchfox.org/mozilla-central/source/third_party/wayland-proxy/wayland-proxy.cpp#596-619):
The proxy detects that reads/writes to the compositor socket have failed (mCompositorFailed)
After a timeout of CLOCKS_PER_SEC (https://searchfox.org/mozilla-central/source/third_party/wayland-proxy/wayland-proxy.cpp#169), it checks if the Wayland display socket file still exists via stat(mWaylandDisplay) (https://searchfox.org/mozilla-central/source/third_party/wayland-proxy/wayland-proxy.cpp#608)
If the socket is gone, it calls WaylandProxy::CompositorCrashed() which triggers WlCompositorCrashHandler() and MOZ_CRASH (https://searchfox.org/mozilla-central/source/widget/gtk/nsWaylandDisplay.cpp#1050-1057)
When a user logs out of a Wayland session, the compositor shuts down and removes the socket file ($XDG_RUNTIME_DIR/wayland-0), which looks identical to a compositor crash from this code's perspective.Firefox does handle SIGTERM on the main thread (https://searchfox.org/mozilla-central/source/widget/gtk/nsAppShell.cpp#413-419), which session managers send during logout. However, the wayland-proxy runs on its own thread (https://searchfox.org/mozilla-central/source/third_party/wayland-proxy/wayland-proxy.cpp#925) with no communication channel back from the main thread. So the proxy can detect the compositor socket disappearing and MOZ_CRASH before the main thread even processes the SIGTERM quit event.
Firefox also listens for PrepareForSleep on org.freedesktop.login1 (https://searchfox.org/mozilla-central/source/widget/gtk/nsAppShell.cpp#204) but not for PrepareForShutdown.
It might be worth exploring our options here. Surely the Wayland proxy should do some AppShutdown::IsInOrBeyond check and avoid crashing if we are shutting down. Maybe we could also listen for PrepareForShutdown or other freedesktop events, similar to what we do on Windows where Firefox handles WM_QUERYENDSESSION and WM_ENDSESSION. Note:
The model is different from Windows. In systemd/login1:
- Proactive inhibitor locks (instead of query/response): An application calls org.freedesktop.login1.Manager.Inhibit(what="shutdown", mode="delay", ...) before any shutdown is requested. This returns a file descriptor — as long as it's held open, systemd will delay (not block) shutdown.
- PrepareForShutdown(true) fires when shutdown is initiated — this is the signal to do final cleanup and release the inhibitor lock.
- Once all delay-type inhibitor locks are released (or InhibitDelayMaxSec expires, default 5 seconds), systemd proceeds with the actual shutdown.
So the mapping is roughly:
- WM_QUERYENDSESSION (can I shut down?) → No direct equivalent. Instead you hold an inhibitor lock proactively, and systemd respects it up to a timeout.
- WM_ENDSESSION (shutdown is happening) → PrepareForShutdown(true)
Note also that on X11 the situation seems to be less a problem as we do not crash on session shutdown, at least.
| Assignee | ||
Comment 25•9 months ago
|
||
AFAIK, the session manager usually wait for a few seconds after sending out SIGTERM. Then, it starts to shutdown the compositor. So, I wounder it can take that long to shutdown Firefox. But, exceptions are always there.
It would be better to remove the connection by return true here [1] instead of crashing Firefox since destroying socket is a part of normal procedure of shutdown or logout.
| Assignee | ||
Comment 26•9 months ago
|
||
Further investigation into the codebase reveals that the disappearance of the Wayland compositor’s named socket—whether due to a compositor crash or a session logout—currently triggers a MOZ_CRASH. Firefox should instead shut down gracefully. While closing all proxy sockets seems like the logical step when they break, doing so triggers a known GLib crash (see Bug 1890074). To bypass this, I propose that WaylandProxy cease message forwarding and instead schedule a QUIT event on the main thread to initiate a clean shutdown.
| Assignee | ||
Comment 27•9 months ago
|
||
When the WaylandProxy detects that the compositor socket has disappeared
(stat() fails on the display path), both compositor crash and normal
Wayland logout produce identical observable state: the socket file is
unlinked in both cases, so no reliable distinction between the two is
possible.
The previous approach called MOZ_CRASH via a CompositorCrashHandler
callback, producing crash reports under WlCompositorCrashHandler. This
made Bug 1925684 the #1 Linux crasher, but nearly all reports were false
positives from normal logouts rather than real compositor crashes.
The fundamental issue is that crashing is the wrong response in either
case. Whether the compositor crashed or the session ended, Firefox cannot
render anything further and should exit cleanly. MOZ_CRASH generates a
misleading minidump that blames Firefox for an external event.
This patch changes the behavior as follows:
-
When stat() fails, WaylandProxy::CompositorUnavailable() is called.
It sets a sCompositorGone flag and invokes a registered handler. -
ProcessConnections() checks sCompositorGone at the top of every
cycle. When set, it drains and discards all pending data from each
application socket instead of forwarding it. This prevents socket
buffer backpressure: if nobody reads from application sockets the
kernel buffers fill, clients' writes stall with EAGAIN, and if
libwayland's send queue overflows it reports a protocol error that
GDK logs and HandleGLibMessage turns into a crash. -
All application sockets are kept open throughout. GTK never observes
a broken pipe and never fires a HandleGLibMessage crash. -
AddToPollFd() and LoadPollFd() skip compositor socket entries
entirely when the compositor is gone. Both functions advance their
pollfd pointer by the same amount so they stay in sync. nfds_max
is sized accordingly. This avoids polling dead sockets whose
persistent POLLERR/POLLHUP would otherwise cause poll() to spin
and consume 100% CPU. -
No new proxy connections are accepted once the compositor is gone,
since there is no compositor to back them. -
If multiple ProxiedConnections exist (one per Firefox process), they
all share the same compositor display path. Once one detects the
compositor is gone the flag applies to all of them instantly, without
each connection waiting out its own sFailureTimeout. -
The handler (WlCompositorUnavailableHandler) dispatches to the main
thread via NS_DispatchToMainThread and calls
nsIAppStartup::Quit(eAttemptQuit). This is a normal, cancellable
shutdown that allows Firefox to save the session and clean up. -
The proxy Run() loop continues polling IsChildAppTerminated(). When
Firefox finishes shutting down, waitpid() returns and the proxy
thread exits cleanly, closing all sockets naturally.
The CompositorCrashHandler typedef and related infrastructure have been
renamed to CompositorUnavailableHandler to reflect the corrected
semantics.
Updated•9 months ago
|
Updated•9 months ago
|
Comment 28•9 months ago
|
||
Lots of newer crashes with this one.
bp-e2765ccc-f903-483b-b6e9-554a60260220 2/20/26, 1:12 PM
bp-64408744-dbe9-4303-bd16-8096a0260220 2/20/26, 1:12 PM
bp-8ecec515-9efd-4776-8524-e5db90260220 2/20/26, 1:12 PM
bp-66b245fe-f582-416f-9554-f98dd0260220 2/20/26, 1:12 PM
bp-aa2e98e5-9df0-4fdf-aec4-a6feb0260220 2/20/26, 1:12 PM
bp-396be351-096a-45e4-9468-c32ed0260220 2/20/26, 1:12 PM
bp-18f52d61-b566-48e3-9bd1-ebae70260203 2/2/26, 7:37 PM
bp-4b680fde-93ea-4332-8a38-5693d0260203 2/2/26, 7:37 PM
Comment 29•9 months ago
|
||
I haven't looked at patch details but can we just get PID of compositor from the socket we're connected to and check the compositor process is present?
Also I tested the logout scenario on Gnome and I haven't seen any Firefox crashes due to closed connections but rather just Firefox quit. Maybe different IDE's have different logout mechanism?
| Assignee | ||
Comment 30•9 months ago
|
||
(In reply to Martin Stránský [:stransky] (ni? me) from comment #29)
I haven't looked at patch details but can we just get PID of compositor from the socket we're connected to and check the compositor process is present?
I can foresee that it could be blocked by containers if there are.
Also I tested the logout scenario on Gnome and I haven't seen any Firefox crashes due to closed connections but rather just Firefox quit. Maybe different IDE's have different logout mechanism?
Usually, firefox should receive SIGTERM before this case happen. However, the runnable handling SIGTERM could be pending on the queue of the main thread if the main thread is very busy.
Comment 31•8 months ago
|
||
(In reply to Thinker Li [:sinker] from comment #30)
(In reply to Martin Stránský [:stransky] (ni? me) from comment #29)
I haven't looked at patch details but can we just get PID of compositor from the socket we're connected to and check the compositor process is present?
I can foresee that it could be blocked by containers if there are.
Let's use compositor PID firts and then fallback to any other solution then. The PID may be the most reliable one.
Also I tested the logout scenario on Gnome and I haven't seen any Firefox crashes due to closed connections but rather just Firefox quit. Maybe different IDE's have different logout mechanism?
Usually, firefox should receive SIGTERM before this case happen. However, the runnable handling SIGTERM could be pending on the queue of the main thread if the main thread is very busy.
Firefox uses direct signal handler outside of any thread.
https://searchfox.org/firefox-main/rev/0894e095dfb46b6dac785365432791a54861fe09/toolkit/profile/nsProfileLock.cpp#123
SIGTERM does emergency quit - it just saves recent profile / removes profile lock and terminates immediately.
Updated•8 months ago
|
Comment 33•8 months ago
|
||
Copying crash signatures from duplicate bugs.
Comment 34•6 months ago
|
||
This signature has been amplifying significantly since Fx150 release, and the crash-ping data is sharp enough that it's worth flagging here while this patch is awaiting review (note that crash-stats data is not showing this spike at all).
Linux release crash-ping shares (~80K Linux pings/day, opt-out):
Apr 13-20 Apr 27-May 04
(Fx149.x) (Fx150.x)
WlCompositorCrashHandler 3.96% 7.31%
HandleGLibMessage 5.61% 8.42%
Both are signatures this patch directly targets: the MOZ_CRASH path, and the libwayland/GDK->GLib log path that the patch description (point 2) explicitly addresses by draining application sockets.
The growth is heavily concentrated on kernel 7.0 (Ubuntu 26.04 LTS, plus rolling distros that picked it up - Arch, CachyOS).
WlCompositorCrashHandler share within kernel-7.0 crashes:
Apr 20 (Fx149.x) 8.3%
Apr 23 (Fx150.0 GA) 9.1%
Apr 27 (Fx150.0) 25.7%
Apr 30 (Fx150.0/0.1) 21.6%
May 02 (Fx150.0.1) 20.9%
May 04 (Fx150.0.1) 19.8%
That's a per-user rate jump locked to the Fx150 rollout - kernel-7.0 population growth (Ubuntu 26.04 LTS, ~7x share growth in 2 weeks) compounds it but isn't the cause.
Likely amplifier: Bug 1940341 (also in 150) removed the transient-error retry block from ConnectToCompositor() (EAGAIN/ECONNREFUSED/EINPROGRESS/... used to retry up to 100x, now any failure -> mCompositorFailed -> straight to ProcessFailure()). On rolling distros with more frequent compositor restarts, that brief window where the socket file is gone is now caught much more often - exactly the path this patch fixes.
Proto-signature is unchanged Fx149->Fx150 (~95% go via ProxiedConnection::ProcessFailure -> WaylandProxy::CompositorCrashed), so no new code path; just the same path firing 2-3x more often.
This patch would eliminate the WlCompositorCrashHandler signature (graceful Quit instead of MOZ_CRASH), and mitigate the HandleGLibMessage co-spike via the application-socket drain.
It wouldn't address the root cause from 1940341 (Firefox concluding compositor-gone too eagerly on transient errors), but it would correctly handle the case where the compositor really did go away, which is what this bug is for.
We may also want a follow up for bug 1940341 to mitigate its impact a bit (retry differently was an option already there, IIUC) ?
Comment 35•6 months ago
|
||
Sure, will review the patch. I think should watch compositor PID there. I can update the patch if needed, depends on Thinker Li.
Updated•6 months ago
|
| Assignee | ||
Comment 37•6 months ago
•
|
||
(In reply to Martin Stránský [:stransky] (ni? me) from comment #31)
(In reply to Thinker Li [:sinker] from comment #30)
(In reply to Martin Stránský [:stransky] (ni? me) from comment #29)
I haven't looked at patch details but can we just get PID of compositor from the socket we're connected to and check the compositor process is present?
I can foresee that it could be blocked by containers if there are.
Let's use compositor PID firts and then fallback to any other solution then. The PID may be the most reliable one.
I need a clarification. What do you suggest here for the case the compositor is still alive or gone?
If the compositor is alive, that mean logging out or someone close the connection and remove the named socket.
If the compositor is dead, that mean the compositor is killed or crash.
Should we handle them differently?
I would expect to exit gracefully for both case.
Comment 38•6 months ago
|
||
(In reply to Thinker Li [:sinker] from comment #37)
I need a clarification. What do you suggest here for the case the compositor is still alive or gone?
If the compositor is alive, that mean logging out or someone close the connection and remove the named socket.
If the compositor is alive and we're disconnected, then there's a protocol error and we were disconnected due of it.
We can keep proxy some time to make sure it's really only client termination and not session quit
(not sure how to get session quit? Via DBus or so?)
If we're disconnected due to protocol error, it's Firefox fault and we should issue crash handler to get info about it.
If the compositor is dead, that mean the compositor is killed or crash.
Yes, so it's compositor fault and we can't do nothing. Ignore the error then, just quit.
| Assignee | ||
Comment 39•6 months ago
•
|
||
(In reply to Martin Stránský [:stransky] (ni? me) from comment #38)
(In reply to Thinker Li [:sinker] from comment #37)
I need a clarification. What do you suggest here for the case the compositor is still alive or gone?
If the compositor is alive, that mean logging out or someone close the connection and remove the named socket.If the compositor is alive and we're disconnected, then there's a protocol error and we were disconnected due of it.
We can keep proxy some time to make sure it's really only client termination and not session quit
(not sure how to get session quit? Via DBus or so?)
If we're disconnected due to protocol error, it's Firefox fault and we should issue crash handler to get info about it.
Firefox should receive a wl_display.error message and crash in WlLogHandler for a protocol error. Previously, we have added a bunch of WlLogHandler_* functions. Protocol errors should not end up here. I notice one except, WlLogHandler ignore still attached errors. Adding this error to the crash reason or sending a telemetry ping may help. By the way, WaylandProxy already waits for 1s before crash.
I checked the history of WaylandProxy. It was landed to mitigate buffer overflow at the compositor side. In this case, Firefox doesn't receive wl_display.error since the server side buffer is full. The bug here is pretty much a similar root cause. For this case, it is better to send a telemetry ping and exit gracefully. WDYT?
| Assignee | ||
Comment 40•6 months ago
|
||
Just found one fact that a wl_display.error message may wait in the queue of a WaylandProxy if the main thread is too busy to read the application socket and the kernel buffer of the socket is full. Once WaylandProxy find that a compositor socket is closed, it stops flushing the corresponding application socket. Messages in the output queue of the application socket will never be sent. When this happen, it may cause this bug or bug 1890074.
If WaylandProxy keep flushing the application socket even it's associated compositor socket is closed, the main thread will receive wl_display.error messages and crash in WlLogHandler instead. Then, we can category them according to crash reasons.
Updated•6 months ago
|
Updated•6 months ago
|
Updated•6 months ago
|
Comment 41•6 months ago
|
||
Comment 42•6 months ago
|
||
| bugherder | ||
Comment 43•6 months ago
|
||
Since the bug is closed, the stalled keyword is now meaningless.
For more information, please visit BugBot documentation.
Comment 44•6 months ago
|
||
Since nightly and release are affected, beta will likely be affected too.
For more information, please visit BugBot documentation.
Updated•6 months ago
|
Updated•6 months ago
|
Comment 45•6 months ago
|
||
This could probably use a Release uplift request.
| Assignee | ||
Comment 46•6 months ago
|
||
(In reply to Ryan VanderMeulen [:RyanVM] from comment #45)
This could probably use a Release uplift request.
This is long lasting issue although it is a s2 bug. I will skip the release uplift.
Updated•6 months ago
|
Description
•