GNOME Bugzilla – Bug 741511
Critical message: NULL is passed to g_object_unref() in spi_atk_state_to_dbus_array()
Last modified: 2015-02-28 19:00:51 UTC
- Open a file with gedit - Select some text and copy it (Ctrl+C) - Quit gedit I have this critical message: > GLib-GObject-CRITICAL **: g_object_unref: assertion 'G_IS_OBJECT (object)' failed The backtrace: (gdb) bt
+ Trace 234423
So g_object_unref() is called with NULL in the spi_atk_state_to_dbus_array() function. I'll attach a patch that fixes the bug, but I'm not sure if it's normal if the AtkStateSet is NULL.
Created attachment 292695 [details] [review] Fix critical message with g_object_unref() The AtkStateSet can be NULL.
(In reply to comment #0) > I'll attach a patch that fixes the bug, but I'm not sure if it's normal if the > AtkStateSet is NULL. In theory it shouldn't, as you should get at least return an empty StateSet. Even if the accessible refers to an object that doesn't exist anymore, the accessible should return an AtkStateSet (and in this case it is a non-empty StateSet, as it should include ATK_STATE_DEFUNCT). Right now, the default atk_object_ref_state_set creates a new empty state set. So each time you get a newly created state set. Most ATK implementors calls always the parent ref_state_set, just adding more states to the set. Looking at gtk (as gedit is a gtk application), only one widget implementation of ref_state_set doesn't call atkobject ref_state_set or creates a new ref_state_set. This is gtkiconviewaccessible: https://git.gnome.org/browse/gtk+/tree/gtk/a11y/gtkiconviewaccessible.c#n816 If the cached state set is null, it just returns null. And looking at the code, that only happens if the object was finalized. So that means that it doesn't handle the DEFUNCT state. So I think that it would be good to confirm that the widget involved is this, and if it is the case, as is just one widget, move the bug there.
Thanks for the information. But I don't have time to investigate this further, I just made the trivial patch if the problem was there.
(In reply to Alejandro Piñeiro Iglesias (IRC: infapi00) from comment #2) I'm getting the same critical message in an app that uses GtkTextView (actually GtkSourceView, but that doesn't seem to be related). In gtk_text_view_accessible_ref_state_set I see: widget = gtk_accessible_get_widget (GTK_ACCESSIBLE (accessible)); if (widget == NULL) return NULL; and that's how I'm getting a NULL AtkStateSet; gtk_button_accessible_ref_state_set does the same thing, also gtk_check_menu_item_accessible_ref_state_set, gtk_expander_accessible_ref_state_set, gtk_toggle_button_accessible_ref_state_set, and gtk_window_accessible_ref_state_set, in addition to the gtkiconviewaccessible noted in comment 2. Should bugs be filed against all of them? Is the correct action to use the parent's vfunc to create the AtkStateSet, as in gtk_color_swatch_accessible_ref_state_set, or atk_state_set_new, as in gtk_cell_accessible_ref_state_set? And should each widget set ATK_STATE_DEFUNCT if its widget is NULL? If returning a NULL AtkStateSet is a programming error, shouldn't spi_atk_state_to_dbus_array g_return_if_fail(set != NULL)?
Created attachment 298158 [details] [review] Patch to gtktextviewaccessible.c Fix gtk_text_view_accessible_ref_state_set to return an AtkStateSet with ATK_STATE_DEFUNCT instead of NULL when its GtkWidget is NULL.
Review of attachment 298158 [details] [review]: thanks