SIGSEGV in _gtk_settings_get_screen() when creating window before activate signal
Steps to reproduce
This test program:
/* gcc -Wall -Wextra -O2 -g $(pkg-config --cflags gtk+-3.0) test.c $(pkg-config --libs gtk+-3.0) -o test */
#include <gtk/gtk.h>
int main() {
/*gtk_init(0, NULL);*/
GtkApplication *app = gtk_application_new(NULL, G_APPLICATION_FLAGS_NONE);
gtk_application_window_new(app);
return 0;
}
crashes when run:
(gdb) r
Starting program: /home/daniel/gtkstuff/test
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib/x86_64-linux-gnu/libthread_db.so.1".
(process:8393): Gtk-CRITICAL **: 12:58:15.904: _gtk_style_provider_private_get_settings: assertion 'GTK_IS_STYLE_PROVIDER_PRIVATE (provider)' failed
(process:8393): Gtk-CRITICAL **: 12:58:15.904: _gtk_style_provider_private_get_settings: assertion 'GTK_IS_STYLE_PROVIDER_PRIVATE (provider)' failed
(process:8393): Gtk-CRITICAL **: 12:58:15.904: _gtk_style_provider_private_get_settings: assertion 'GTK_IS_STYLE_PROVIDER_PRIVATE (provider)' failed
Program received signal SIGSEGV, Segmentation fault.
_gtk_settings_get_screen (settings=0x0) at ../../../../gtk/gtksettings.c:3348
3348 ../../../../gtk/gtksettings.c: No such file or directory.
Uncommenting the gtk_init();
makes the crash go away and causes the expected warning to be shown:
$ ./test
(test:8514): Gtk-CRITICAL **: 13:05:24.256: New application windows must be added after the GApplication::startup signal has been emitted.
Version information
This is with Kubuntu 20.04 and its GTK+ 3.24.20 (running KDE though which may be a reason for a CSS/theme issue? just guessing).
Warnings
(see above)
Backtrace
(gdb) bt
#0 _gtk_settings_get_screen (settings=0x0) at ../../../../gtk/gtksettings.c:3348
#1 0x00007ffff797de0c in gtk_css_value_icon_theme_compute (icon_theme=<optimized out>, property_id=<optimized out>, provider=<optimized out>, style=<optimized out>, parent_style=<optimized out>) at ../../../../gtk/gtkcssiconthemevalue.c:84
#2 0x00007ffff799e307 in gtk_css_static_style_compute_value (style=0x555555594040 [GtkCssStaticStyle], provider=0x0, parent_style=0x0, id=3, specified=0x7ffff7f9fb20 <inherit>, section=0x0) at ../../../../gtk/gtkcssstaticstyle.c:237
#3 0x00007ffff7989492 in _gtk_css_lookup_resolve (lookup=lookup@entry=0x555555592000, provider=provider@entry=0x0, style=style@entry=0x555555594040 [GtkCssStaticStyle], parent_style=parent_style@entry=0x0) at ../../../../gtk/gtkcsslookup.c:122
#4 0x00007ffff799e232 in gtk_css_static_style_new_compute (provider=provider@entry=0x0, matcher=matcher@entry=0x0, parent=parent@entry=0x0) at ../../../../gtk/gtkcssstaticstyle.c:195
#5 0x00007ffff799e28d in gtk_css_static_style_get_default () at ../../../../gtk/gtkcssstaticstyle.c:164
#6 0x00007ffff7989ec6 in gtk_css_node_init (cssnode=0x555555588220 [GtkCssNode]) at ../../../../gtk/gtkcssnode.c:667
#7 0x00007ffff6cc5131 in g_type_create_instance (type=<optimized out>) at ../../../gobject/gtype.c:1861
#8 0x00007ffff6ca434d in g_object_new_internal (class=class@entry=0x55555558fe80, params=params@entry=0x0, n_params=n_params@entry=0) at ../../../gobject/gobject.c:1937
#9 0x00007ffff6ca5b45 in g_object_new_with_properties (object_type=0x55555558f4f0 [GtkCssWidgetNode/GtkCssNode], n_properties=0, names=names@entry=0x0, values=values@entry=0x0) at ../../../gobject/gobject.c:2105
#10 0x00007ffff6ca66f1 in g_object_new (object_type=<optimized out>, first_property_name=first_property_name@entry=0x0) at ../../../gobject/gobject.c:1777
#11 0x00007ffff79a6c1f in gtk_css_widget_node_new (widget=widget@entry=0x5555555902b0 [GtkWidget]) at ../../../../gtk/gtkcsswidgetnode.c:297
#12 0x00007ffff7b85d8d in gtk_widget_init (instance=0x5555555902b0 [GtkWidget], g_class=0x55555558eef0) at ../../../../gtk/gtkwidget.c:4468
#13 0x00007ffff6cc5131 in g_type_create_instance (type=<optimized out>) at ../../../gobject/gtype.c:1861
#14 0x00007ffff6ca434d in g_object_new_internal (class=class@entry=0x55555558eef0, params=params@entry=0x7fffffffdba0, n_params=n_params@entry=1) at ../../../gobject/gobject.c:1937
#15 0x00007ffff6ca6378 in g_object_new_valist (object_type=<optimized out>, first_property_name=<optimized out>, var_args=var_args@entry=0x7fffffffdcf0) at ../../../gobject/gobject.c:2262
#16 0x00007ffff6ca66cd in g_object_new (object_type=<optimized out>, first_property_name=<optimized out>) at ../../../gobject/gobject.c:1780
#17 0x0000555555555099 in main () at test.c:6