GNOME Bugzilla – Bug 665551
Segfault and other difficulties with 'input' signal handlers for Gtk.SpinButton
Last modified: 2014-08-22 01:40:18 UTC
Created attachment 202763 [details] A simple test case that demonstrates the bug in question Using Python 3.2.2 and pygobject 3.0.2, I found myself wanting to handle the 'input' signal on a Gtk.SpinButton. Checking the docs for gtk's C api showed the callback is passed a pointer to a gdouble as an out parameter, and is expected to return a gboolean. Included as an attachment is a small test case. Connecting to that signal with pygobject, I found that returning None from the callback causes a segfault, as does returning a python float or just about anything else. When that is done, the following is written to stderr: "/usr/lib/python3.2/site-packages/gi/types.py:43: Warning: g_value_get_double: assertion `G_VALUE_HOLDS_DOUBLE (value)' failed return info.invoke(*args, **kwargs) TypeError: can't convert return value to desired type /usr/lib/python3.2/site-packages/gi/types.py:43: Warning: gtype.c:4199: type id `0' is invalid return info.invoke(*args, **kwargs) /usr/lib/python3.2/site-packages/gi/types.py:43: Warning: can't peek value table for type `<invalid>' which is not currently referenced return info.invoke(*args, **kwargs) Segmentation fault" Modifying the callback to return a bool instead does not cause a segfault, but the first time either button is pressed or input is entered into the spin button, the following is written to stderr: "/usr/lib/python3.2/site-packages/gi/types.py:43: Warning: g_value_get_double: assertion `G_VALUE_HOLDS_DOUBLE (value)' failed return info.invoke(*args, **kwargs)" Subsequent button presses or input do not trigger the warning again. Now, the segfaulting is obviously something that needs to be fixed, but my guess is fixing that part will still leave the main issue unaddressed, which is that pygobject seems to lack a way to properly handle callbacks with `out` parameters. I might be missing something, though. Perhaps there is a way to do that already, but I've been unable to find any documentation to that effect.
Confirming that it crashes with pygobject 3.2.0 and Python 2.7: /opt/gnome3/lib64/python2.7/site-packages/gi/types.py:43: Warning: g_value_get_double: assertion `G_VALUE_HOLDS_DOUBLE (value)' failed return info.invoke(*args, **kwargs) TypeError: can't convert return value to desired type /opt/gnome3/lib64/python2.7/site-packages/gi/types.py:43: Warning: gtype.c:4206: type id `0' is invalid return info.invoke(*args, **kwargs) /opt/gnome3/lib64/python2.7/site-packages/gi/types.py:43: Warning: can't peek value table for type `<invalid>' which is not currently referenced return info.invoke(*args, **kwargs)
+ Trace 230117
*** This bug has been marked as a duplicate of bug 644927 ***