GNOME Bugzilla – Bug 614150
SIGFPE when GtkBuilder sets GtkEntryCompletion::text_column
Last modified: 2018-02-10 03:22:31 UTC
Setting GtkEntryCompletion::set_text_column in a GtkBuilder UI seems to be causing a SIGFPE when the completion popup first appears. In this case, I am using a GtkEntryCompletion object constructed from a GtkBuilder UI file, then setting the model and associating it with a GtkEntry programmatically. If the GtkEntryCompletion definition in the UI file contains a text_column property, when the completer popup first appears the program dies with a SIGFPE and this backtrace: Program received signal SIGFPE, Arithmetic exception. 0x00007ffff4c3b1ee in _gtk_entry_completion_resize_popup (completion=0xeb62c0) at /build/buildd/gtk+2.0-2.20.0/gtk/gtkentrycompletion.c:1414 1414 /build/buildd/gtk+2.0-2.20.0/gtk/gtkentrycompletion.c: No such file or directory. in /build/buildd/gtk+2.0-2.20.0/gtk/gtkentrycompletion.c (gdb) bt
+ Trace 221134
If call GtkEntryCompletion::set_text_column programmatically, this does not occur. This is on a amd64 machine running Ubuntu Lucid and libgtk2.0-0 2.20.0-0ubuntu2 installed.
This is because GtkBuilder does not use gtk_entry_completion_set_text_column but instead sets the property through g_object_set or similar. The same is true for applications that access Gtk through GI such as gjs. Using the function and setting the property directly are quite different things for GtkEntryCompletion as the documentation for gtk_entry_completion_set_text_column states: This functions creates and adds a GtkCellRendererText for the selected column. If you need to set the text column, but don't want the cell renderer, use g_object_set() to set the "text-column" property directly. This means the CellRenderer will not be created when setting the property directly. According to the above piece of documentation this was intentional at the time the function was introduced and thus not a bug. Yet, nowadays with GtkBuilder and GI I would consider this behaviour a bug indeed. The problem is, though, that fixing this would probably mean making g_object_set (…, "text-column", …) behave the same way as gtk_entry_completion_set_text_column and would therefore break the contract. For this reason it can likely only be fixed in Gtk 4.0, i.e. when API breaking changes are allowed again. Correct me if I am wrong.
I don't believe constructing implied cell renderers under the hood is a very good idea. It makes sense for a convenience api as there is some explicit documentation telling us that some implied renderer will be created. For GtkBuilder files, the files should specify a cell renderer, this allows proper straight forward deserialization of xml, if you missed adding a cell renderer, then you should add the GtkCellRenderer (or derived type) of your choice to the entry. If the property used to associate the text-column with the cell renderer property automatically adds a cell renderer, that would block the possibility of using a cell renderer of your choice, so you would no longer be able to use a custom renderer without a world of pain (i.e. after building the file, you will have to manually remove the 'implicitly added renderer' so that only your custom renderer remains).
Of course, that is not to say that GTK+ has any excuse for crashing when fed some invalid input. There should of course instead be a readable hint: g_warning("text-column set on GtkEntryCompletion with no cell renderer present");
We're moving to gitlab! As part of this move, we are closing bugs that haven't seen activity in more than 5 years. If this issue is still imporant to you and still relevant with GTK+ 3.22 or master, please consider creating a gitlab issue for it.