GNOME Bugzilla – Bug 777871
cuisine-page: missing argument to g_signal_emit_by_name can cause a segfault
Last modified: 2017-01-30 11:59:46 UTC
I had borrowed this otherwise great code for my program, and in my build today, it was segfaulting via g_signal_emit_by_name(). This was because of the missing location for the return. Adding that makes it work again. https://developer.gnome.org/gobject/stable/gobject-Signals.html#g-signal-emit-by-name The valist must be: > parameters to be passed to the signal, followed by a location for the > return value. If the return type of the signal is G_TYPE_NONE, the > return value location can be omitted. That is not the case for ScrolledWindow::scroll-child, which returns a gboolean: https://developer.gnome.org/gtk3/stable/GtkScrolledWindow.html#GtkScrolledWindow-scroll-child So we need to pass in a dummy gboolean to sink the return value.
the (boring) relevant part of the backtrace after I called g_signal_emit_by_name with the FALSE (horizontal scrolling) being the last argument in the valist: > (ins)(gdb) bt > #0 0x00007ffff45b103b in ?? () from /usr/lib/x86_64-linux-gnu/libgobject-2.0.so.0 > #1 0x00007ffff45a1caf in g_signal_emit_valist () from /usr/lib/x86_64-linux-gnu/libgobject-2.0.so.0 > #2 0x00007ffff45a245b in g_signal_emit_by_name () from /usr/lib/x86_64-linux-gnu/libgobject-2.0.so.0
Created attachment 344457 [details] [review] [PATCH] cuisine-page: Add missing return sink for signal > A signal with a return type other than G_TYPE_NONE expects “parameters > to be passed to the signal, followed by a location for the return value” > but the latter was not being supplied here. This can cause a segfault > because the valist doesn’t contain the number of arguments GLib expects.
Created attachment 344458 [details] [review] [PATCH] cuisine-page: Add missing return sink for signal (fixed the author name. I always forget my local git defaults get in the way)