segfault when changing color of GtkColorButton with label
A GtkColorButton with a label set will segfault the application once the color of it is set.
How to reproduce
Create these files:
gtk_button_crash.c
:
#include <gtk/gtk.h>
static void on_app_activate(GApplication *app, gpointer data) {
GtkWidget *window = gtk_application_window_new(GTK_APPLICATION(app));
GtkWidget *btn = gtk_color_button_new();
gtk_button_set_label(GTK_BUTTON(btn), "Set my Color!");
gtk_container_add(GTK_CONTAINER(window), btn);
gtk_widget_show_all(window);
}
int main(int argc, char **argv) {
GtkApplication *app = gtk_application_new("org.example.color_button_crash",
G_APPLICATION_FLAGS_NONE);
g_signal_connect(app, "activate", G_CALLBACK(on_app_activate), NULL);
int status = g_application_run(G_APPLICATION(app), argc, argv);
g_object_unref(app);
return status;
}
CMakeLists.txt
:
project(gtk_button_crash C)
cmake_minimum_required(VERSION 2.6)
find_package(PkgConfig REQUIRED)
pkg_check_modules(GTK3 REQUIRED gtk+-3.0)
include_directories(${GTK3_INCLUDE_DIRS})
link_directories(${GTK3_LIBRARY_DIRS})
add_definitions(${GTK3_CFLAGS_OTHER})
add_executable(gtk_button_crash gtk_button_crash.c)
target_link_libraries(gtk_button_crash ${GTK3_LIBRARIES})
Build it
cmake .
make
Run it
G_DEBUG_MESSAGES=all ./gtk_button_crash
Follow instructions in screenshot
When run with G_DEBUG_MESSAGES=all
, this program outputs
(gtk_button_crash:53739): GLib-GIO-DEBUG: 15:45:43.430: _g_io_module_get_default: Found default implementation local (GLocalVfs) for ‘gio-vfs’
(gtk_button_crash:53739): GLib-DEBUG: 15:45:43.456: unsetenv() is not thread-safe and should not be used after threads are created
(gtk_button_crash:53739): Gtk-DEBUG: 15:45:43.456: Connecting to session manager
(gtk_button_crash:53739): Gtk-DEBUG: 15:45:43.457: Failed to get the GNOME session proxy: The name org.gnome.SessionManager is not owned
(gtk_button_crash:53739): Gtk-DEBUG: 15:45:43.457: Failed to get the Xfce session proxy: The name org.xfce.SessionManager is not owned
(gtk_button_crash:53739): Gtk-DEBUG: 15:45:43.457: Failed to get an inhibit portal proxy: The name org.freedesktop.portal.Desktop is not owned
(gtk_button_crash:53739): GLib-GIO-DEBUG: 15:45:45.366: _g_io_module_get_default: Found default implementation dconf (DConfSettingsBackend) for ‘gsettings-backend’
(gtk_button_crash:53739): dconf-DEBUG: 15:45:45.367: watch_fast: "/org/gtk/settings/color-chooser/" (establishing: 0, active: 0)
(gtk_button_crash:53739): dconf-DEBUG: 15:45:45.368: watch_established: "/org/gtk/settings/color-chooser/" (establishing: 1)
(gtk_button_crash:53739): Gtk-DEBUG: 15:45:45.384: org.gnome.Shell.Screenshot not provided
(gtk_button_crash:53739): Gtk-DEBUG: 15:45:45.385: org.kde.kwin.ColorPicker not provided
(gtk_button_crash:53739): Gtk-DEBUG: 15:45:45.385: No suitable GtkColorPicker implementation
(gtk_button_crash:53739): dconf-DEBUG: 15:45:45.386: change_fast
(gtk_button_crash:53739): dconf-DEBUG: 15:45:45.386: change_fast
(gtk_button_crash:53739): dconf-DEBUG: 15:45:45.386: change_fast
(gtk_button_crash:53739): dconf-DEBUG: 15:45:45.386: change_notify: /org/gtk/settings/color-chooser/selected-color
(gtk_button_crash:53739): dconf-DEBUG: 15:45:45.386: change_fast
(gtk_button_crash:53739): dconf-DEBUG: 15:45:45.389: change_fast
(gtk_button_crash:53739): dconf-DEBUG: 15:45:45.389: change_notify: /org/gtk/settings/color-chooser/selected-color
(gtk_button_crash:53739): dconf-DEBUG: 15:45:45.389: change_fast
(gtk_button_crash:53739): dconf-DEBUG: 15:45:45.924: change_fast
(gtk_button_crash:53739): dconf-DEBUG: 15:45:45.924: change_notify: /org/gtk/settings/color-chooser/selected-color
(gtk_button_crash:53739): GLib-GObject-WARNING **: 15:45:46.699: g_object_notify: object class 'GtkLabel' has no property named 'rgba'
and then segfaults.
Expected behaviour
The program runs as expected, without crashing when changing the color of the GtkColorButton
.
Backtrace
Created by running the binary with gdb
, using the backtrace
gdb command.
0x00007ffff722c925 in g_type_check_instance_is_fundamentally_a () from /usr/lib/libgobject-2.0.so.0
(gdb) backtrace
#0 0x00007ffff722c925 in g_type_check_instance_is_fundamentally_a ()
at /usr/lib/libgobject-2.0.so.0
#1 0x00007ffff7213c6f in g_object_ref () at /usr/lib/libgobject-2.0.so.0
#2 0x00007ffff72087c5 in g_cclosure_marshal_VOID__OBJECTv ()
at /usr/lib/libgobject-2.0.so.0
#3 0x00007ffff72271c0 in g_signal_emit_valist ()
at /usr/lib/libgobject-2.0.so.0
#4 0x00007ffff7227330 in g_signal_emit () at /usr/lib/libgobject-2.0.so.0
#5 0x00007ffff79b95c8 in () at /usr/lib/libgtk-3.so.0
#6 0x00007ffff72271c0 in g_signal_emit_valist ()
at /usr/lib/libgobject-2.0.so.0
#7 0x00007ffff7227330 in g_signal_emit () at /usr/lib/libgobject-2.0.so.0
#8 0x00007ffff72271c0 in g_signal_emit_valist ()
at /usr/lib/libgobject-2.0.so.0
#9 0x00007ffff7227330 in g_signal_emit () at /usr/lib/libgobject-2.0.so.0
#10 0x00007ffff7a7eb86 in () at /usr/lib/libgtk-3.so.0
#11 0x00007ffff792fff9 in () at /usr/lib/libgtk-3.so.0
#12 0x00007ffff7911d9e in () at /usr/lib/libgtk-3.so.0
#13 0x00007ffff7911dd3 in () at /usr/lib/libgtk-3.so.0
#14 0x00007ffff7911dd3 in () at /usr/lib/libgtk-3.so.0
#15 0x00007ffff78f50c3 in () at /usr/lib/libgtk-3.so.0
#16 0x00007ffff72271c0 in g_signal_emit_valist ()
at /usr/lib/libgobject-2.0.so.0
#17 0x00007ffff7227330 in g_signal_emit () at /usr/lib/libgobject-2.0.so.0
#18 0x00007ffff7742100 in () at /usr/lib/libgdk-3.so.0
#19 0x00007ffff772f5dc in () at /usr/lib/libgdk-3.so.0
#20 0x00007ffff7113a84 in () at /usr/lib/libglib-2.0.so.0
#21 0x00007ffff71133e5 in g_main_context_dispatch ()
at /usr/lib/libglib-2.0.so.0
#22 0x00007ffff7167749 in () at /usr/lib/libglib-2.0.so.0
#23 0x00007ffff7110bc1 in g_main_context_iteration ()
at /usr/lib/libglib-2.0.so.0
#24 0x00007ffff73282ee in g_application_run () at /usr/lib/libgio-2.0.so.0
#25 0x0000555555555326 in main ()
Environment info
- Gtk3 Version:
pkg-config --modversion gtk+-3.0
outputs3.24.30
- OS: Arch Linux with 5.14.12 kernel
- Desktop: xorg
1.20.13
with i3-gaps4.19.1
Edited by LordMZTE