After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 777871 - cuisine-page: missing argument to g_signal_emit_by_name can cause a segfault
cuisine-page: missing argument to g_signal_emit_by_name can cause a segfault
Status: RESOLVED FIXED
Product: recipes
Classification: Other
Component: general
unspecified
Other Linux
: Normal normal
: ---
Assigned To: Recipes maintainer(s)
Recipes maintainer(s)
Depends on:
Blocks:
 
 
Reported: 2017-01-28 14:35 UTC by Daniel Boles
Modified: 2017-01-30 11:59 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
[PATCH] cuisine-page: Add missing return sink for signal (1.65 KB, patch)
2017-01-28 14:37 UTC, Daniel Boles
none Details | Review
[PATCH] cuisine-page: Add missing return sink for signal (1.66 KB, patch)
2017-01-28 14:39 UTC, Daniel Boles
committed Details | Review

Description Daniel Boles 2017-01-28 14:35:10 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.
Comment 1 Daniel Boles 2017-01-28 14:36:52 UTC
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
Comment 2 Daniel Boles 2017-01-28 14:37:46 UTC
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.
Comment 3 Daniel Boles 2017-01-28 14:39:12 UTC
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)