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 669496 - Array argument to Python signal callbacks cause crash
Array argument to Python signal callbacks cause crash
Status: RESOLVED OBSOLETE
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
Depends on: 726999 727004
Blocks:
 
 
Reported: 2012-02-06 18:02 UTC by Paolo Borelli
Modified: 2018-01-10 20:13 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
unit test showing the problem (1.13 KB, text/plain)
2012-02-06 18:03 UTC, Paolo Borelli
  Details
test case (866 bytes, text/plain)
2012-04-04 14:27 UTC, Martin Pitt
  Details
test case for signal (812 bytes, patch)
2013-02-27 12:28 UTC, Martin Pitt
committed Details | Review

Description Paolo Borelli 2012-02-06 18:02:04 UTC
I saw the following g-i commit:

http://git.gnome.org/browse/gobject-introspection/commit/?id=6757460e4a95f818d3a73d7904ef8a7afb6987fc


I do not think pygobject handles it. Attached there is a very quick unit test which indeed does not pass (though it may also the unit test being buggy, it was a 3 minutes hack just to check if array callbacks were already working)
Comment 1 Paolo Borelli 2012-02-06 18:03:07 UTC
Created attachment 206923 [details]
unit test showing the problem
Comment 2 Martin Pitt 2012-04-04 14:26:14 UTC
It's indeed not working well. The test case needs to be fixed a bit, though:

test_callback_array_arg (test_everything.TestCallbacks) ... TypeError: callback() takes exactly 2 arguments (4 given)

When the callback signature gets changed to actually take the two length arguments

        def callback(ints, ints_len, strings, strings_len):

it gets a little further:

AssertionError: Lists differ: [] != [-1, 0, 1, 2]

So the array arguments indeed do not get marshalled correctly.

Finally, I think the test case should also check the return value of test_array_callback(). It's supposed to return the sum of the two callback() returns, which is 1 the first time and 2 the second. This shows that the return value is utter bogus:

AssertionError: 2038473632 != 3
Comment 3 Martin Pitt 2012-04-04 14:27:19 UTC
Created attachment 211298 [details]
test case

Updated test case. Not marking as patch, to get this bug off the patch review queue, and it is not a solution for this bug.
Comment 4 Martin Pitt 2013-02-27 12:28:36 UTC
Created attachment 237518 [details] [review]
test case for signal

While debugging bug 693994 I noticed a similar problem: signals which receive a GArray argument do not work. They fail with

** (runtests.py:22846): CRITICAL **: Stack overflow protection. Can't copy array element into GIArgument.

that's because _pygi_argument_to_object() is being called with an array of GValues, not an array of uints as it would expect.

I just wanted to put this new test case somewhere.
Comment 5 Simon Feltman 2013-08-15 02:47:52 UTC
Comment on attachment 211298 [details]
test case

The issue this test case was showing already seems to be fixed (and a similar test case already exists): 
https://git.gnome.org/browse/pygobject/tree/tests/test_everything.py?id=3.9.5#n687
Comment 6 Simon Feltman 2013-08-15 03:06:47 UTC
Comment on attachment 237518 [details] [review]
test case for signal

Verified this test still crashes. Marking as a patch again because we can commit it with @unittest.skip and a message pointing to this bug report.
Comment 7 Garrett Regier 2014-07-23 14:50:49 UTC
When digging into the code I have found multiple issues when it comes to passing arrays into callbacks and in the case of bug 702508, vfuncs. It seems like a better approach would be to work on bug 727004 instead of trying to fix broken marshaling as a test case already exists for passing arrays into a function and works as expected. Am I correct in my understanding of the state of pygobject in regards to the marshaling code?

I would like to fix these issues and any performance boost from using the cache is highly desired. However, I am missing a bit of info on how to unify the two marshaling paths so they both use the cache and avoid pygi-argument.c's marshaling.
Comment 8 Simon Feltman 2014-08-08 01:23:18 UTC
I'm afraid this one is going to require work going into bug 726999 as well.
Comment 9 Simon Feltman 2014-08-08 09:34:47 UTC
Comment on attachment 237518 [details] [review]
test case for signal

Committed test case with @unittest.skip
Comment 10 GNOME Infrastructure Team 2018-01-10 20:13:57 UTC
-- GitLab Migration Automatic Message --

This bug has been migrated to GNOME's GitLab instance and has been closed from further activity.

You can subscribe and participate further through the new bug through this link to our GitLab instance: https://gitlab.gnome.org/GNOME/pygobject/issues/23.