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 647581 - Flags do not seem to work on signal handlers
Flags do not seem to work on signal handlers
Status: RESOLVED FIXED
Product: pygobject
Classification: Bindings
Component: introspection
unspecified
Other Linux
: Normal normal
: ---
Assigned To: Nobody's working on this now (help wanted and appreciated)
Python bindings maintainers
: 649630 (view as bug list)
Depends on:
Blocks:
 
 
Reported: 2011-04-12 16:15 UTC by Ignacio Casal Quinteiro (nacho)
Modified: 2011-08-13 10:14 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
test.py (3.55 KB, text/x-python)
2011-04-12 16:15 UTC, Ignacio Casal Quinteiro (nacho)
  Details
accelmap.ui (6.77 KB, application/x-designer)
2011-04-12 16:15 UTC, Ignacio Casal Quinteiro (nacho)
  Details
Handle arguments that are flags (833 bytes, patch)
2011-05-12 16:59 UTC, Sebastian Pölsterl
none Details | Review

Description Ignacio Casal Quinteiro (nacho) 2011-04-12 16:15:08 UTC
I am attaching a small program so you can see it by yourself.
Comment 1 Ignacio Casal Quinteiro (nacho) 2011-04-12 16:15:40 UTC
Created attachment 185799 [details]
test.py

main program
Comment 2 Ignacio Casal Quinteiro (nacho) 2011-04-12 16:15:59 UTC
Created attachment 185800 [details]
accelmap.ui

ui file
Comment 3 Ignacio Casal Quinteiro (nacho) 2011-04-12 16:16:51 UTC
You just have to do python test.py and then intro in the accel to be edited and then try to press i.e control+M, M is entered but control is not detected, it is always passed 0 to the handler.
Comment 4 Sebastian Pölsterl 2011-05-12 16:52:18 UTC
*** Bug 649630 has been marked as a duplicate of this bug. ***
Comment 5 Sebastian Pölsterl 2011-05-12 16:59:04 UTC
Created attachment 187724 [details] [review]
Handle arguments that are flags

The attached patch should fix this issue, could you please check.
Comment 6 Ignacio Casal Quinteiro (nacho) 2011-07-04 17:24:32 UTC
Well, the patch looks good to me although I'm getting a crash in the invoke-rewrote branch and not sure if it really fixes the problem
Comment 7 johnp 2011-07-05 15:56:48 UTC
I'll take a look on the invoke-rewrite branch today
Comment 8 johnp 2011-07-05 17:57:11 UTC
What crash are you seeing?  It works fine for me with this patch.
Comment 9 johnp 2011-07-05 17:58:06 UTC
BTW is there a way we can have a unit test for this?
Comment 10 Ignacio Casal Quinteiro (nacho) 2011-07-05 18:10:50 UTC
Here is the bt. See that I'm using a plugin not exactly the code attached in this bug report. So probably it is another issue

Program received signal SIGSEGV, Segmentation fault.
0x00007fffe60b104b in pygi_marshal_cleanup_args_in_parameter_fail (state=
    0x7fffffffb040, cache=0x16934c0, failed_arg_index=4294967295)
    at pygi-marshal-cleanup.c:141
141	        gpointer data = state->args[i]->v_pointer;
(gdb) bt
  • #0 pygi_marshal_cleanup_args_in_parameter_fail
    at pygi-marshal-cleanup.c line 141
  • #1 _invoke_marshal_in_args
    at pygi-invoke-ng.c line 303
  • #2 _wrap_g_callable_info_invoke
  • #3 ext_do_call
    at /usr/src/debug/Python-2.7.1/Python/ceval.c line 4382
  • #4 PyEval_EvalFrameEx
    at /usr/src/debug/Python-2.7.1/Python/ceval.c line 2761
  • #5 PyEval_EvalCodeEx
  • #6 fast_function
    at /usr/src/debug/Python-2.7.1/Python/ceval.c line 4168
  • #7 call_function
    at /usr/src/debug/Python-2.7.1/Python/ceval.c line 4093
  • #8 PyEval_EvalFrameEx
    at /usr/src/debug/Python-2.7.1/Python/ceval.c line 2722
  • #9 PyEval_EvalCodeEx
    at /usr/src/debug/Python-2.7.1/Python/ceval.c line 3312
  • #10 function_call
    at remote 0x11e5d70>, <...>), kw=0x0) at /usr/src/debug/Python-2.7.1/Objects/funcobject.c line 526
  • #11 PyObject_Call
    at /usr/src/debug/Python-2.7.1/Objects/abstract.c line 2529
  • #12 PyEval_CallObjectWithKeywords
    at remote 0x11e5d70>, <...>), kw=<optimized out>) at /usr/src/debug/Python-2.7.1/Python/ceval.c line 3941
  • #13 _pygi_closure_handle
    at pygi-closure.c line 356
  • #14 ffi_closure_unix64_inner
    at src/x86/ffi64.c line 563
  • #15 ffi_closure_unix64
    at src/x86/unix64.S line 228
  • #16 gtk_buildable_parser_finished
    at gtkbuildable.c line 197
  • #17 _gtk_builder_parser_parse_buffer
    at gtkbuilderparser.c line 1184
  • #18 gtk_builder_add_from_file
    at gtkbuilder.c line 901
  • #19 ffi_call_unix64
    at src/x86/unix64.S line 75
  • #20 ffi_call
  • #21 _g_callable_info_invoke
    at girepository/gicallableinfo.c line 518
  • #22 g_function_info_invoke
    at girepository/gifunctioninfo.c line 273
  • #23 _invoke_callable
    at pygi-invoke-ng.c line 52
  • #24 _wrap_g_callable_info_invoke
  • #25 ext_do_call
    at /usr/src/debug/Python-2.7.1/Python/ceval.c line 4382
  • #26 PyEval_EvalFrameEx
    at /usr/src/debug/Python-2.7.1/Python/ceval.c line 2761
  • #27 PyEval_EvalCodeEx
  • #28 fast_function
    at /usr/src/debug/Python-2.7.1/Python/ceval.c line 4168
  • #29 call_function
    at /usr/src/debug/Python-2.7.1/Python/ceval.c line 4093
  • #30 PyEval_EvalFrameEx
    at /usr/src/debug/Python-2.7.1/Python/ceval.c line 2722
  • #31 PyEval_EvalCodeEx
    at /usr/src/debug/Python-2.7.1/Python/ceval.c line 3312
  • #32 function_call
    at remote 0xca3f00>, <Action at remote 0x11e5a50>, None), kw=0x0) at /usr/src/debug/Python-2.7.1/Objects/funcobject.c line 526
  • #33 PyObject_Call
  • #34 instancemethod_call
    at remote 0xca3f00>, <Action at remote 0x11e5a50>, None), kw=0x0) at /usr/src/debug/Python-2.7.1/Objects/classobject.c line 2578
  • #35 PyObject_Call
    at /usr/src/debug/Python-2.7.1/Objects/abstract.c line 2529
  • #36 PyEval_CallObjectWithKeywords
  • #37 pygi_signal_closure_marshal
    at pygi-signal-closure.c line 168
  • #38 g_closure_invoke
    at gclosure.c line 773
  • #39 signal_emit_unlocked_R
  • #40 g_signal_emit_valist
    at gsignal.c line 2987
  • #41 g_signal_emit
    at gsignal.c line 3044
  • #42 _gtk_action_emit_activate
    at gtkaction.c line 799
  • #43 gtk_action_activate
    at gtkaction.c line 829
  • #44 gtk_real_menu_item_activate
    at gtkmenuitem.c line 1831
  • #45 g_cclosure_marshal_VOID__VOID
    at gmarshal.c line 85
  • #46 g_type_class_meta_marshal
    at gclosure.c line 884
  • #47 g_closure_invoke
    at gclosure.c line 773
  • #48 signal_emit_unlocked_R
  • #49 g_signal_emit_valist
    at gsignal.c line 2987
  • #50 g_signal_emit
    at gsignal.c line 3044
  • #51 gtk_widget_activate
    at gtkwidget.c line 6136
  • #52 gtk_menu_shell_activate_item
    at gtkmenushell.c line 1404
  • #53 gtk_menu_shell_button_release
    at gtkmenushell.c line 803
  • #54 gtk_menu_button_release
    at gtkmenu.c line 3473
  • #55 _gtk_marshal_BOOLEAN__BOXED
    at gtkmarshalers.c line 85
  • #56 g_type_class_meta_marshal
    at gclosure.c line 884
  • #57 g_closure_invoke
    at gclosure.c line 773
  • #58 signal_emit_unlocked_R
    at gsignal.c line 3294
  • #59 g_signal_emit_valist
    at gsignal.c line 2997
  • #60 g_signal_emit
    at gsignal.c line 3044
  • #61 gtk_widget_event_internal
    at gtkwidget.c line 6105
  • #62 gtk_widget_event
    at gtkwidget.c line 5821
  • #63 gtk_propagate_event
    at gtkmain.c line 2599
  • #64 gtk_main_do_event
    at gtkmain.c line 1874
  • #65 _gdk_event_emit
    at gdkevents.c line 71
  • #66 gdk_event_source_dispatch
    at gdkeventsource.c line 360
  • #67 g_main_dispatch
    at gmain.c line 2500
  • #68 g_main_context_dispatch
    at gmain.c line 3083
  • #69 g_main_context_iterate
    at gmain.c line 3161
  • #70 g_main_loop_run
    at gmain.c line 3369
  • #71 gtk_main
    at gtkmain.c line 1357
  • #72 gedit_main
    at gedit.c line 199
  • #73 main
    at gedit.c line 290

Comment 11 johnp 2011-07-05 19:17:36 UTC
Ok, it failed while processing one of the args and is iterating over the processed args to free them.  It looks like it is most likely going past the bounds of the state->args array.  Ah, i must be -1 :-)  Didn't cover that edge case.
Comment 12 johnp 2011-07-05 19:40:15 UTC
So I don get it, failed_arg_index=4294967295  which I am guessing is 0 - 1 if it were unsigned but i is an int and failed_arg_index is a gssize, both of which are signed values.  i most likely should also be gssize.
Comment 13 johnp 2011-07-05 19:59:39 UTC
Ok, so the compiler most likely doesn't cast the int to the larger gssize.  Please check out the latest which contains this bug's patch.  I made it so all arg indexes use gssize instead of int or gsize.  We still use gsize for arrays but if a parameter list is greater than the max of gssize that API has issues.
Comment 14 Ignacio Casal Quinteiro (nacho) 2011-07-07 14:22:35 UTC
Seems to not crash now, although now I am getting this other problem :(

Traceback (most recent call last):
  • File "/home/nacho/.local/share/gedit/plugins/acceleditor/accelmap.py", line 135 in do_parser_finished
    Gtk.AccelMap.foreach(None, self.populate_treeview)
  • File "/opt/gnome/lib64/python2.7/site-packages/gi/types.py", line 44 in function
    return info.invoke(*args)
TypeError: Argument 0 does not allow None as a value

Comment 15 johnp 2011-07-07 17:55:06 UTC
The first parameter of foreach is not marked allow none.
Comment 16 Ignacio Casal Quinteiro (nacho) 2011-07-07 21:25:54 UTC
dunno, see that it is data, and it was working in pygobject 2.28
Comment 17 johnp 2011-07-08 15:14:45 UTC
It works in pygobject 2.28 because they were lax with testing for allow none.  invoke-rewrite is much stricter (and safer in that regard).  If introspection wants to assume that data allows none it should mark it as such.  Can you annotate Gtk+ and tell me if it works?  If it does, feel free to just commit it.
Comment 18 Ignacio Casal Quinteiro (nacho) 2011-07-09 11:11:59 UTC
Works perfect thanks. Pushed to gtk-3-0 and master.