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 665551 - Segfault and other difficulties with 'input' signal handlers for Gtk.SpinButton
Segfault and other difficulties with 'input' signal handlers for Gtk.SpinButton
Status: RESOLVED DUPLICATE of bug 644927
Product: pygobject
Classification: Bindings
Component: introspection
3.2.x
Other Linux
: Normal normal
: ---
Assigned To: Nobody's working on this now (help wanted and appreciated)
Python bindings maintainers
Depends on: 727004
Blocks:
 
 
Reported: 2011-12-04 19:30 UTC by Cass
Modified: 2014-08-22 01:40 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
A simple test case that demonstrates the bug in question (266 bytes, text/x-python)
2011-12-04 19:30 UTC, Cass
Details

Description Cass 2011-12-04 19:30:22 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.
Comment 1 Sebastian Pölsterl 2012-04-21 14:06:53 UTC
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)

  • #0 g_signal_emit_valist
    at gsignal.c line 3308
  • #1 g_signal_emit
    at gsignal.c line 3352
  • #2 gtk_spin_button_update
    at gtkspinbutton.c line 2577
  • #3 gtk_spin_button_button_press
    at gtkspinbutton.c line 1356
  • #4 _gtk_marshal_BOOLEAN__BOXEDv
    at gtkmarshalers.c line 130
  • #5 g_type_class_meta_marshalv
    at gclosure.c line 997
  • #6 _g_closure_invoke_va
    at gclosure.c line 840
  • #7 g_signal_emit_valist
    at gsignal.c line 3207
  • #8 g_signal_emit
    at gsignal.c line 3352
  • #9 gtk_widget_event_internal
    at gtkwidget.c line 6380
  • #10 gtk_widget_event
    at gtkwidget.c line 6037
  • #11 propagate_event_up
    at gtkmain.c line 2390
  • #12 propagate_event
    at gtkmain.c line 2490
  • #13 gtk_propagate_event
    at gtkmain.c line 2525
  • #14 gtk_main_do_event
    at gtkmain.c line 1660
  • #15 _gdk_event_emit
    at gdkevents.c line 69
  • #16 gdk_event_source_dispatch
    at gdkeventsource.c line 358
  • #17 g_main_dispatch
    at gmain.c line 2539
  • #18 g_main_context_dispatch
    at gmain.c line 3075
  • #19 g_main_context_iterate
    at gmain.c line 3146
  • #20 g_main_loop_run
    at gmain.c line 3340
  • #21 gtk_main
    at gtkmain.c line 1161
  • #22 ffi_call_unix64
    at ../src/x86/unix64.S line 75
  • #23 ffi_call
    at ../src/x86/ffi64.c line 486
  • #24 g_callable_info_invoke
    at girepository/gicallableinfo.c line 610
  • #25 g_function_info_invoke
    at girepository/gifunctioninfo.c line 274
  • #26 _invoke_callable
    at pygi-invoke.c line 52
  • #27 _wrap_g_callable_info_invoke
  • #28 ext_do_call
    at /usr/src/debug/Python-2.7.2/Python/ceval.c line 4400
  • #29 PyEval_EvalFrameEx
    at /usr/src/debug/Python-2.7.2/Python/ceval.c line 2779
  • #30 PyEval_EvalCodeEx
  • #31 fast_function
    at /usr/src/debug/Python-2.7.2/Python/ceval.c line 4186
  • #32 call_function
    at /usr/src/debug/Python-2.7.2/Python/ceval.c line 4111
  • #33 PyEval_EvalFrameEx
    at /usr/src/debug/Python-2.7.2/Python/ceval.c line 2740
  • #34 PyEval_EvalCodeEx
    at /usr/src/debug/Python-2.7.2/Python/ceval.c line 3330
  • #35 PyEval_EvalCode
    at /usr/src/debug/Python-2.7.2/Python/ceval.c line 689
  • #36 run_mod
  • #37 PyRun_FileExFlags
  • #38 PyRun_SimpleFileExFlags
    at /usr/src/debug/Python-2.7.2/Python/pythonrun.c line 944
  • #39 Py_Main
    at /usr/src/debug/Python-2.7.2/Modules/main.c line 599
  • #40 __libc_start_main
    at libc-start.c line 226
  • #41 _start

Comment 2 Simon Feltman 2014-08-22 01:40:18 UTC

*** This bug has been marked as a duplicate of bug 644927 ***