gnome-shell crashed with SIGTRAP from error "Can't create a GtkStyleContext without a display connection" in gtk_style_context_init

Bug #1949200 reported by Hans-Petter Falao
42
This bug affects 3 people
Affects Status Importance Assigned to Milestone
gnome-shell (Ubuntu)
Won't Fix
High
Unassigned
libcanberra (Ubuntu)
Fix Released
High
Marco Trevisan (Treviño)
Kinetic
Won't Fix
Undecided
Unassigned

Bug Description

GNOME Shell isn't meant to use GTK at all, but it's repeatedly crashing in GTK since the introduction of GNOME 40.

https://errors.ubuntu.com/problem/45d4ce4e8f26828ab6993261e8a20208ecf261b0
https://errors.ubuntu.com/problem/e60359af65f32c18a4a6ccc93fd3469b0e675844
https://errors.ubuntu.com/problem/73a93ba578f68516e680373ae324db01336e8bad
https://errors.ubuntu.com/problem/d69ccaf1379f588b04ecac2a6cc93b9be31100b4

This seems to be a result of Xwayland crashing and gnome-shell then trying to recover (and failing). Although gnome-shell shouldn't be using GTK, and Wayland sessions shouldn't be dependent on having an X11 server (Xwayland) available. Fixing either of those should resolve this.

WORKAROUND:

sudo apt remove libcanberra-gtk3-module

TEST CASE:

1. Log into a Wayland session.
2. Open a Terminal.
3. $ xrandr # Just to ensure Xwayland starts
4. $ killall Xwayland

Expected: gnome-shell still responds.
Observed: gnome-shell freezes or exits.

---

ProblemType: Crash
DistroRelease: Ubuntu 22.04
Package: gnome-shell 40.5-1ubuntu2
ProcVersionSignature: Ubuntu 5.13.0-19.19-generic 5.13.14
Uname: Linux 5.13.0-19-generic x86_64
ApportVersion: 2.20.11-0ubuntu72
Architecture: amd64
CasperMD5CheckResult: pass
CrashCounter: 1
CurrentDesktop: ubuntu:GNOME
Date: Fri Oct 29 15:11:43 2021
DisplayManager: gdm3
ExecutablePath: /usr/bin/gnome-shell
InstallationDate: Installed on 2021-10-27 (2 days ago)
InstallationMedia: Ubuntu 22.04 LTS "Jammy Jellyfish" - Alpha amd64 (20211023)
ProcCmdline: /usr/bin/gnome-shell
ProcEnviron:
 LANG=nb_NO.UTF-8
 LANGUAGE=nb_NO:nb:no_NO:no:nn_NO:nn:en
 PATH=(custom, no user)
 SHELL=/bin/bash
 XDG_RUNTIME_DIR=<set>
RelatedPackageVersions: mutter-common 40.5-1ubuntu2
Signal: 5
SourcePackage: gnome-shell
StacktraceTop:
 g_log_writer_default () from /lib/x86_64-linux-gnu/libglib-2.0.so.0
 g_log_structured_array () from /lib/x86_64-linux-gnu/libglib-2.0.so.0
 g_log_structured_standard () from /lib/x86_64-linux-gnu/libglib-2.0.so.0
 ?? () from /lib/x86_64-linux-gnu/libgtk-3.so.0
 g_type_create_instance () from /lib/x86_64-linux-gnu/libgobject-2.0.so.0
Title: gnome-shell crashed with signal 5 in g_log_writer_default()
UpgradeStatus: No upgrade log present (probably fresh install)
UserGroups: adm cdrom dip lpadmin lxd plugdev sambashare sudo
separator:

Revision history for this message
Hans-Petter Falao (la9ui) wrote :
Revision history for this message
Apport retracing service (apport) wrote :

StacktraceTop:
 g_log_writer_default (log_level=<optimized out>, fields=0x7ffeb0f37560, n_fields=6, user_data=0x0) at ../../../glib/gmessages.c:556
 g_log_structured_array (n_fields=6, fields=0x7ffeb0f37560, log_level=G_LOG_LEVEL_ERROR) at ../../../glib/gmessages.c:1972
 g_log_structured_array (log_level=G_LOG_LEVEL_ERROR, fields=0x7ffeb0f37560, n_fields=6) at ../../../glib/gmessages.c:1945
 g_log_structured_standard (log_domain=log_domain@entry=0x7f2752a4c063 "Gtk", log_level=log_level@entry=G_LOG_LEVEL_ERROR, file=file@entry=0x7f2752ab20e0 "../../../../gtk/gtkstylecontext.c", line=line@entry=0x7f2752a6be7c "348", func=func@entry=0x7f2752ab2c30 <__func__.70> "gtk_style_context_init", message_format=message_format@entry=0x7f2752ab2400 "Can't create a GtkStyleContext without a display connection") at ../../../glib/gmessages.c:2029
 gtk_style_context_init (context=0x559c3bcdd5d0) at ../../../../gtk/gtkstylecontext.c:348

tags: removed: need-amd64-retrace
Revision history for this message
Daniel van Vugt (vanvugt) wrote :

Unfortunately:

 * we don't have all the debug symbols in that crash

 * I can't find any reports of similar crashes from other people

 * Many of your installed packages are from [origin: unknown]

If you are using any PPAs then please remove them from the system. Please also update your system by:

  sudo apt update
  sudo apt full-upgrade

and then reboot.

Next time a crash happens, please open a new bug. Hopefully we can match this up to some future crash, or it may never happen again after the packages are updated.

Changed in gnome-shell (Ubuntu):
status: New → Incomplete
Revision history for this message
Daniel van Vugt (vanvugt) wrote :

Please also ensure you don't have the 'proposed' channel enabled.

Revision history for this message
Daniel van Vugt (vanvugt) wrote :

Sorry I was focussing on the attached files when comment #2 actually looks quite detailed.

summary: - gnome-shell crashed with signal 5 in g_log_writer_default()
+ gnome-shell crashed with signal 5 error "Can't create a GtkStyleContext
+ without a display connection" in gtk_style_context_init
Changed in gnome-shell (Ubuntu):
status: Incomplete → New
Revision history for this message
Daniel van Vugt (vanvugt) wrote : Re: gnome-shell crashed with signal 5 error "Can't create a GtkStyleContext without a display connection" in gtk_style_context_init

I wonder if this bug might be caused by missing the fix:

  https://gitlab.gnome.org/GNOME/gdm/-/merge_requests/156

Revision history for this message
Daniel van Vugt (vanvugt) wrote :

Also sounds like https://gitlab.gnome.org/GNOME/mutter/-/issues/1475 ... that was closed without a fix because it was found to be caused by a faulty extension.

Revision history for this message
Daniel van Vugt (vanvugt) wrote :

Incomplete because I would like to see this crash occur on a clean system without so many unknown packages installed. Although if it turns out to be bug 1948617 then it certainly warrants attention.

Changed in gnome-shell (Ubuntu):
status: New → Incomplete
Revision history for this message
Apport retracing service (apport) wrote :

StacktraceTop:
 g_log_writer_default (log_level=<optimized out>, fields=0x7ffeb0f37560, n_fields=6, user_data=0x0) at ../../../glib/gmessages.c:556
 g_log_structured_array (n_fields=6, fields=0x7ffeb0f37560, log_level=G_LOG_LEVEL_ERROR) at ../../../glib/gmessages.c:1972
 g_log_structured_array (log_level=G_LOG_LEVEL_ERROR, fields=0x7ffeb0f37560, n_fields=6) at ../../../glib/gmessages.c:1945
 g_log_structured_standard (log_domain=log_domain@entry=0x7f2752a4c063 "Gtk", log_level=log_level@entry=G_LOG_LEVEL_ERROR, file=file@entry=0x7f2752ab20e0 "../../../../gtk/gtkstylecontext.c", line=line@entry=0x7f2752a6be7c "348", func=func@entry=0x7f2752ab2c30 <__func__.70> "gtk_style_context_init", message_format=message_format@entry=0x7f2752ab2400 "Can't create a GtkStyleContext without a display connection") at ../../../glib/gmessages.c:2029
 gtk_style_context_init (context=0x559c3bcdd5d0) at ../../../../gtk/gtkstylecontext.c:348

Revision history for this message
Apport retracing service (apport) wrote : Stacktrace.txt
Revision history for this message
Apport retracing service (apport) wrote : StacktraceSource.txt
Revision history for this message
Apport retracing service (apport) wrote : ThreadStacktrace.txt
Changed in gnome-shell (Ubuntu):
importance: Undecided → Medium
Revision history for this message
Daniel van Vugt (vanvugt) wrote : Re: gnome-shell crashed with signal 5 error "Can't create a GtkStyleContext without a display connection" in gtk_style_context_init

Interesting the above attachments show the problem originating from:

#29 0x00007f2746b35bfe in free_sound_event (d=0x7f273808bf20) at /build/libcanberra-NELJAC/libcanberra-0.30/src/canberra-gtk-module.c:184

which is kind of similar to https://gitlab.gnome.org/GNOME/mutter/-/issues/1475 where GTK is the problem.

What gnome-shell extensions are you using?

information type: Private → Public
summary: - gnome-shell crashed with signal 5 error "Can't create a GtkStyleContext
- without a display connection" in gtk_style_context_init
+ gnome-shell crashed with SIGTRAP from error "Can't create a
+ GtkStyleContext without a display connection" in gtk_style_context_init
Revision history for this message
Daniel van Vugt (vanvugt) wrote :

The instruction addresses (modulo 16 at least) seem to match up too well to be a coincidence so I believe this is:

https://errors.ubuntu.com/problem/45d4ce4e8f26828ab6993261e8a20208ecf261b0
https://errors.ubuntu.com/problem/e60359af65f32c18a4a6ccc93fd3469b0e675844
https://errors.ubuntu.com/problem/73a93ba578f68516e680373ae324db01336e8bad

which cumulatively make this the top gnome-shell crasher in impish.

description: updated
Changed in gnome-shell (Ubuntu):
importance: Medium → High
status: Incomplete → Confirmed
tags: added: impish
Revision history for this message
Daniel van Vugt (vanvugt) wrote :

Like the similar upstream bug https://gitlab.gnome.org/GNOME/mutter/-/issues/1475, this appears to be caused by the intersection of:

 (a) GTK being used in the gnome-shell process (usually by extensions); and

 (b) The absence of an Xserver for GTK to connect to (Xwayland is only started on-demand now).

It looks like one possible offender using GTK is gnome-shell-extension-appindicator. I'm not sure about the other extensions, and it's hard to tell with desktop-icons-ng which in theory uses GTK in a safe way (in a separate client process).

Revision history for this message
Daniel van Vugt (vanvugt) wrote (last edit ):

If we could then it would be nice to mitigate this by simply ensuring GTK in the gnome-shell process can find the Wayland server automatically instead of X11. Because if we don't find a blanket solution like that then we'll keep getting similar gnome-shell crash reports.

Changed in gtk+3.0 (Ubuntu):
status: New → Confirmed
importance: Undecided → High
description: updated
description: updated
Revision history for this message
Daniel van Vugt (vanvugt) wrote :

Interestingly, the source of this particular crash is canberra-gtk-module.c from libcanberra 0.30. That's the latest version but it's also from 2012 so Wayland support might not be great. It appears you can safely just uninstall it:

  sudo apt remove libcanberra-gtk3-module

so I wonder if anyone finds that avoids the crash?

Revision history for this message
Daniel van Vugt (vanvugt) wrote :

Seems my development (impish) machine encountered the crash only once, yesterday, and logged:

Nov 02 13:40:39 kab gnome-shell[1614]: Connection to xwayland lost
Nov 02 13:40:39 kab pulseaudio[1472]: X11 I/O error handler called
Nov 02 13:40:39 kab pulseaudio[1472]: X11 I/O error exit handler called, preparing to tear down X11 modules
Nov 02 13:40:39 kab gnome-shell[1614]: Xwayland just died, attempting to recover
Nov 02 13:40:39 kab systemd[1463]: org.gnome.SettingsDaemon.XSettings.service: Failed with result 'exit-code'.
Nov 02 13:40:39 kab gnome-shell[1614]: invalid unclassed pointer in cast to 'GObject'
Nov 02 13:40:39 kab gnome-shell[1614]: g_object_get_data: assertion 'G_IS_OBJECT (object)' failed
Nov 02 13:40:39 kab gnome-shell[1614]: gdk_screen_get_display: assertion 'GDK_IS_SCREEN (screen)' failed
Nov 02 13:40:39 kab gnome-shell[1614]: gdk_display_get_name: assertion 'GDK_IS_DISPLAY (display)' failed
Nov 02 13:40:39 kab gnome-shell[1614]: gdk_screen_get_number: assertion 'GDK_IS_SCREEN (screen)' failed
Nov 02 13:40:39 kab gnome-shell[1614]: gtk_settings_get_for_screen: assertion 'GDK_IS_SCREEN (screen)' failed
Nov 02 13:40:39 kab gnome-shell[1614]: invalid unclassed pointer in cast to 'GObject'
Nov 02 13:40:39 kab gnome-shell[1614]: g_object_set_data_full: assertion 'G_IS_OBJECT (object)' failed
Nov 02 13:40:39 kab gnome-shell[1614]: Can't create a GtkStyleContext without a display connection

But errors.ubuntu.com failed to associate it with a known error ID. Maybe we also need to make sure PulseAudio isn't doing any X11.

Revision history for this message
Launchpad Janitor (janitor) wrote :

Status changed to 'Confirmed' because the bug affects multiple users.

Changed in gnome-shell-extension-appindicator (Ubuntu):
status: New → Confirmed
Revision history for this message
Daniel van Vugt (vanvugt) wrote :

Seems like killing your Xwayland process is an easy way to reproduce this crash.

Revision history for this message
Daniel van Vugt (vanvugt) wrote :

Removed appindicator task because I've confirmed it happens without any extensions loaded (duplicate bug 1966862).

no longer affects: gnome-shell-extension-appindicator (Ubuntu)
description: updated
description: updated
tags: added: rls-jj-incoming
Revision history for this message
Daniel van Vugt (vanvugt) wrote (last edit ):

Confirmed! The workaround/fix is:

  sudo apt remove libcanberra-gtk3-module

Also I can't find an active bug tracker for libcanberra and its last release was in 2012.

affects: gtk+3.0 (Ubuntu) → ubuntu
affects: ubuntu → libcanberra (Ubuntu)
description: updated
Changed in libcanberra (Ubuntu):
status: Confirmed → Triaged
Changed in gnome-shell (Ubuntu):
status: Confirmed → Triaged
description: updated
tags: added: dt-303
Revision history for this message
Heather Ellsworth (hellsworth) wrote :

If the solution is to remove libcanberra-gtk3-module and since it hasn't been touched since 2012, do we need to provide it at all?

Revision history for this message
Marco Trevisan (Treviño) (3v1n0) wrote (last edit ):
Download full text (5.0 KiB)

This is the root issue: https://gitlab.gnome.org/GNOME/glib/-/issues/389

Stacktrace:

(gdb) bt
#0 g_log_writer_default (log_level=<optimized out>, fields=0x7ffcf2f236c0, n_fields=6, user_data=0x0) at ../../../glib/gmessages.c:557
#1 0x00007f355eb3cc93 in g_log_structured_array (n_fields=6, fields=0x7ffcf2f236c0, log_level=G_LOG_LEVEL_ERROR) at ../../../glib/gmessages.c:1973
#2 g_log_structured_array (log_level=G_LOG_LEVEL_ERROR, fields=0x7ffcf2f236c0, n_fields=6) at ../../../glib/gmessages.c:1946
#3 0x00007f355eb3ce93 in g_log_structured_standard (log_domain=log_domain@entry=0x7f355e6be063 "Gtk", log_level=log_level@entry=G_LOG_LEVEL_ERROR,
    file=file@entry=0x7f355e724138 "../../../../gtk/gtkstylecontext.c", line=line@entry=0x7f355e6ddea4 "348",
    func=func@entry=0x7f355e724c70 <__func__.70> "gtk_style_context_init",
    message_format=message_format@entry=0x7f355e724458 "Can't create a GtkStyleContext without a display connection") at ../../../glib/gmessages.c:2030
#4 0x00007f355e5b45cf in gtk_style_context_init (context=0x555ee32475d0) at ../../../../gtk/gtkstylecontext.c:348
#5 0x00007f355ec57efa in g_type_create_instance (type=<optimized out>) at ../../../gobject/gtype.c:1929
#6 0x00007f355ec3ef4d in g_object_new_internal (class=class@entry=0x555ee2ec1c60, params=params@entry=0x0, n_params=n_params@entry=0)
    at ../../../gobject/gobject.c:2011
#7 0x00007f355ec401ad in g_object_new_with_properties (object_type=93866027507792, n_properties=0, names=names@entry=0x0, values=values@entry=0x0)
    at ../../../gobject/gobject.c:2181
#8 0x00007f355ec40cb1 in g_object_new (object_type=<optimized out>, first_property_name=<optimized out>) at ../../../gobject/gobject.c:1821
#9 0x00007f355e393f80 in _gtk_style_new_for_path (screen=0x0, path=path@entry=0x555ee2ccd4b0) at ../../../../gtk/deprecated/gtkstyle.c:854
#10 0x00007f355e3941f3 in gtk_style_new () at ../../../../gtk/deprecated/gtkstyle.c:888
#11 0x00007f355e398b71 in gtk_widget_get_default_style () at ../../../../gtk/deprecated/gtkstyle.c:4061
#12 gtk_widget_get_default_style () at ../../../../gtk/deprecated/gtkstyle.c:4050
#13 0x00007f355e65e8ee in gtk_widget_real_destroy (object=0x555ee3d54320) at ../../../../gtk/gtkwidget.c:12356
#14 0x00007f355dec62a7 in ?? () from /lib/x86_64-linux-gnu/libmutter-10.so.0
#15 0x00007f355ec2ed2f in g_closure_invoke (closure=0x555ee10ccac0, return_value=0x0, n_param_values=1, param_values=0x7ffcf2f24180,
    invocation_hint=0x7ffcf2f24100) at ../../../gobject/gclosure.c:830
#16 0x00007f355ec4aae0 in signal_emit_unlocked_R (node=node@entry=0x555ee0fcd450, detail=detail@entry=0, instance=instance@entry=0x555ee3d54320,
    emission_return=emission_return@entry=0x0, instance_and_params=instance_and_params@entry=0x7ffcf2f24180) at ../../../gobject/gsignal.c:3861
#17 0x00007f355ec4c554 in g_signal_emit_valist (instance=<optimized out>, signal_id=<optimized out>, detail=<optimized out>,
    var_args=var_args@entry=0x7ffcf2f24330) at ../../../gobject/gsignal.c:3496
#18 0x00007f355ec4c7a3 in g_signal_emit (instance=instance@entry=0x555ee3d54320, signal_id=<optimized out>, detail=detail@entry=0)
    at ../../../gobject/gsignal.c:3553
#19 0x00007f...

Read more...

Changed in gnome-shell (Ubuntu):
status: Triaged → Won't Fix
Changed in libcanberra (Ubuntu):
status: Triaged → Fix Committed
assignee: nobody → Marco Trevisan (Treviño) (3v1n0)
Revision history for this message
Launchpad Janitor (janitor) wrote :

This bug was fixed in the package libcanberra - 0.30-10ubuntu1

---------------
libcanberra (0.30-10ubuntu1) jammy; urgency=medium

  * Merge with debian, remaining changes:
    - Disable login sound by default and hide sound from startup applications
    - Install the gtk plugin in the unity-settings-daemon dir
  * debian/gbp.conf: Update with ubuntu settings
  * debian/control: Update reference to ubuntu branches
  * debian/changelog: Add missing entries lost during merges
  * debian/changelog: Fix Heather's email address
  * debian/patches: Refresh

libcanberra (0.30-10) unstable; urgency=medium

  * debian/patches/gtk_dont_assume_x11.patch: Avoid more X11-only codepaths

libcanberra (0.30-9) unstable; urgency=medium

  * debian/patches: Refresh
  * debian/patches: Handle display closing gracefully (LP: #1949200)

 -- Marco Trevisan (Treviño) <email address hidden> Sat, 09 Apr 2022 01:34:34 +0200

Changed in libcanberra (Ubuntu):
status: Fix Committed → Fix Released
Revision history for this message
Alberts Muktupāvels (muktupavels) wrote :

3v1n0, gtk-module-Handle-display-closing-gracefully.patch introduced regression!

Why are you setting d->object to NULL in on_object_disposed? By doing that you are introducing memory leak, no? Creating SoundEventData structure strong reference is added, it must be removed otherwise object will never get finalized!?

I am attaching small test app that can be used to reproduce problem - it simply prints warning messages when GObject / GtkWindow is disposed and/or finalized.

Basically looks like now canberra-gtk-module adds two extra refs that are not removed. Also with attached test app free_sound_event now is never called with d->object != NULL.

Revision history for this message
Marco Trevisan (Treviño) (3v1n0) wrote :

> Why are you setting d->object to NULL in on_object_disposed? By doing that you are introducing memory leak, no?

Well the point was that I didn't want this to happen when last reference was removed, but this can't really happen in a sane setup unless something played some dirty game with the object.

So that's fine, I've handled it as part of fix for #1983794

Revision history for this message
Timo Aaltonen (tjaalton) wrote : Please test proposed package

Hello Hans-Petter, or anyone else affected,

Accepted libcanberra into kinetic-proposed. The package will build now and be available at https://launchpad.net/ubuntu/+source/libcanberra/0.30-10ubuntu1.22.10.1 in a few hours, and then in the -proposed repository.

Please help us by testing this new package. See https://wiki.ubuntu.com/Testing/EnableProposed for documentation on how to enable and use -proposed. Your feedback will aid us getting this update out to other Ubuntu users.

If this package fixes the bug for you, please add a comment to this bug, mentioning the version of the package you tested, what testing has been performed on the package and change the tag from verification-needed-kinetic to verification-done-kinetic. If it does not fix the bug for you, please add a comment stating that, and change the tag to verification-failed-kinetic. In either case, without details of your testing we will not be able to proceed.

Further information regarding the verification process can be found at https://wiki.ubuntu.com/QATeam/PerformingSRUVerification . Thank you in advance for helping!

N.B. The updated package will be released to -updates after the bug(s) fixed by this package have been verified and the package has been in -proposed for a minimum of 7 days.

Changed in libcanberra (Ubuntu Kinetic):
status: New → Fix Committed
tags: added: verification-needed verification-needed-kinetic
Revision history for this message
Utkarsh Gupta (utkarsh) wrote :

Ubuntu 22.10 (Kinetic Kudu) has reached end of life, so this bug will not be fixed for that specific release.

Changed in libcanberra (Ubuntu Kinetic):
status: Fix Committed → Won't Fix
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Duplicates of this bug

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.