After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 791647 - _gtk_style_provider_private_get_settings(provider==NULL) crashes with SIGSEGV at gtkstyleproviderprivate.c:123, called from gtk_css_value_initial_compute ... gtk_css_static_style_new_compute(NULL, NULL, NULL)
_gtk_style_provider_private_get_settings(provider==NULL) crashes with SIGSEGV...
Status: RESOLVED OBSOLETE
Product: gtk+
Classification: Platform
Component: .General
3.22.x
Other Linux
: Normal major
: ---
Assigned To: gtk-bugs
gtk-bugs
Depends on:
Blocks:
 
 
Reported: 2017-12-15 07:32 UTC by Daniel van Vugt
Modified: 2018-05-02 19:36 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
0001-Don-t-SEGV-when-missing-default-settings-or-screen.patch (1.73 KB, patch)
2017-12-15 09:45 UTC, Daniel van Vugt
rejected Details | Review

Description Daniel van Vugt 2017-12-15 07:32:09 UTC
_gtk_style_provider_private_get_settings(provider==NULL) crashes with SIGSEGV at gtkstyleproviderprivate.c:123, called from:
gtk_css_value_initial_compute
gtk_css_static_style_compute_value
_gtk_css_lookup_resolve
gtk_css_static_style_new_compute(NULL, NULL, NULL)
gtk_css_static_style_get_default

This is occurring in Ubuntu a lot:
https://errors.ubuntu.com/problem/92c580cf48dae63a366ee45b28a16be710f70347 (https://launchpad.net/bugs/1552577)

Also reported in Fedora (different process, same stack trace):
https://bugzilla.redhat.com/show_bug.cgi?id=1395968
Comment 1 Daniel van Vugt 2017-12-15 07:40:11 UTC
It appears this is triggered initially by gtk_settings_get_default() returning NULL, which it is allowed to do. So at some point after that we need to start treating the NULL as an error before it gets dereferenced later...


GtkCssStyle *
gtk_css_static_style_get_default (void)
{
  /* FIXME: This really depends on the screen, but we don't have
   * a screen at hand when we call this function, and in practice,
   * the default style is always replaced by something else
   * before we use it.
   */
  if (default_style == NULL)
    {
      GtkSettings *settings;

      settings = gtk_settings_get_default ();
      default_style = gtk_css_static_style_new_compute (GTK_STYLE_PROVIDER (settings),
                                                        NULL,
                                                        NULL);
      g_object_set_data_full (G_OBJECT (settings), I_("gtk-default-style"),
                              default_style, clear_default_style);
    }

  return default_style;
}
Comment 2 Daniel van Vugt 2017-12-15 07:55:55 UTC
Or just not depend on gtk_settings_get_default() at all, as the FIXME comment implies.
Comment 3 Daniel van Vugt 2017-12-15 09:45:34 UTC
Created attachment 365584 [details] [review]
0001-Don-t-SEGV-when-missing-default-settings-or-screen.patch

I'm no GTK expert, but here's a quick fix that does actually work in practice and should work in all cases in theory.

If someone else has a better idea, that's good too.
Comment 4 Daniel Boles 2017-12-15 12:55:58 UTC
Review of attachment 365584 [details] [review]:

::: gtk/gtkcssstaticstyle.c
@@ +156,3 @@
       GtkSettings *settings;
 
+      g_warn_if_fail (settings = gtk_settings_get_default ());

just IMO this looks weird and I think it'd be better style to keep the assignment and warning separate. So you could move this into the if (!settings) block as a call to g_warning().
Comment 5 Matthias Clasen 2017-12-15 19:23:57 UTC
Review of attachment 365584 [details] [review]:

::: gtk/gtkcssstaticstyle.c
@@ +158,3 @@
+      g_warn_if_fail (settings = gtk_settings_get_default ());
+      if (!settings)  /* Just means there is no default GDK screen right now */
+        settings = g_object_new (GTK_TYPE_SETTINGS, NULL);

no, that is not ok.
Comment 6 Daniel van Vugt 2017-12-18 01:38:07 UTC
No worries. Just reject my patch and someone can deal with it later.

Lots of other things going on at the moment so quite distracted.
Comment 7 Daniel Boles 2018-03-13 10:10:16 UTC
Comment on attachment 365584 [details] [review]
0001-Don-t-SEGV-when-missing-default-settings-or-screen.patch

rejecting as requested. Does anyone have an alternative suggestion?
Comment 8 GNOME Infrastructure Team 2018-05-02 19:36:18 UTC
-- GitLab Migration Automatic Message --

This bug has been migrated to GNOME's GitLab instance and has been closed from further activity.

You can subscribe and participate further through the new bug through this link to our GitLab instance: https://gitlab.gnome.org/GNOME/gtk/issues/994.