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 722899 - boxed structures not copied when passed in a callback without transfer
boxed structures not copied when passed in a callback without transfer
Status: RESOLVED FIXED
Product: pygobject
Classification: Bindings
Component: general
Git master
Other Linux
: Normal normal
: ---
Assigned To: Nobody's working on this now (help wanted and appreciated)
Python bindings maintainers
: 695056 (view as bug list)
Depends on: 726999
Blocks:
 
 
Reported: 2014-01-24 11:10 UTC by Mike Gorse
Modified: 2014-08-18 08:33 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
Add test to gimarshallingtests (2.54 KB, patch)
2014-01-24 11:15 UTC, Mike Gorse
reviewed Details | Review
pygobject test (963 bytes, patch)
2014-01-24 11:16 UTC, Mike Gorse
none Details | Review
fixed pygobject test. (936 bytes, patch)
2014-01-24 11:21 UTC, Mike Gorse
none Details | Review
Improved test (gobject-introspection part) (2.31 KB, patch)
2014-01-26 21:51 UTC, Mike Gorse
committed Details | Review
Revised test (pygobject version) (1.04 KB, patch)
2014-01-26 21:58 UTC, Mike Gorse
committed Details | Review

Description Mike Gorse 2014-01-24 11:10:35 UTC
If a callback passes a boxced structure without giving ownership to the callback (ie, uses transfer none), then pygobject does not copy the boxed structure when needed.

Will attach a test case.
Comment 1 Christoph Reiter (lazka) 2014-01-24 11:13:49 UTC
See https://bugzilla.gnome.org/show_bug.cgi?id=695056
Comment 2 Mike Gorse 2014-01-24 11:15:57 UTC
Created attachment 267122 [details] [review]
Add test to gimarshallingtests
Comment 3 Mike Gorse 2014-01-24 11:16:33 UTC
Created attachment 267123 [details] [review]
pygobject test
Comment 4 Mike Gorse 2014-01-24 11:21:09 UTC
Created attachment 267124 [details] [review]
fixed pygobject test.

Remove a stupid print I had for debugging. Anyway, the test currently fails.
Comment 5 Simon Feltman 2014-01-24 22:09:15 UTC
Just a heads up, fixing this will be tricky because it will break some API expectation in use today. Specifically gtk_tree_model_iter_next's 'iter' argument is marked as [in], which is somewhat incorrect. Unfortunately, this sees usage for vfunc implementors which modify the iter input argument to get it to iterate to the next node.

https://developer.gnome.org/gtk3/stable/GtkTreeModel.html#gtk-tree-model-iter-next

So I think fixing this would break people who rely on the pass a by reference behaviour and fixing the annotation to [inout] would also break the API. This might be a rare case but we either need to special case this methods argument or come up with some other strategie so it continues working.
Comment 6 Simon Feltman 2014-01-24 22:13:57 UTC
Review of attachment 267122 [details] [review]:

Thanks for the tests.

::: tests/gimarshallingtests.c
@@ +4376,3 @@
+  GIMarshallingTestsBoxedStruct *box;
+
+glong

Just a thought and I'm not sure it is possible, but it would be nice if we could use a static allocation of the boxed. This way after the callback is run, the value held by the boxed could be tweaked (here in C), then the Python tests could verify its version of the boxed has not been tweaked. This would allow for an "expected failure" on the Python side, instead of just a potentially skipped test.
Comment 7 Simon Feltman 2014-01-24 22:18:19 UTC
*** Bug 695056 has been marked as a duplicate of this bug. ***
Comment 8 Mike Gorse 2014-01-26 21:51:51 UTC
Created attachment 267255 [details] [review]
Improved test (gobject-introspection part)

Thanks for the review. I've modified the test to keep the box around and increment its long_ value each time the function is called.
Comment 9 Mike Gorse 2014-01-26 21:58:52 UTC
Created attachment 267258 [details] [review]
Revised test (pygobject version)

This currently fails (returns 2, but it should return 1 if pygobject makes a copy of the struct).
Comment 10 Simon Feltman 2014-01-27 01:36:47 UTC
Review of attachment 267255 [details] [review]:

looks good to me.
Comment 11 Simon Feltman 2014-01-27 01:42:25 UTC
Review of attachment 267258 [details] [review]:

Looks good. Feel free to commit this with:

    @unittest.skipUnless(hasattr(GIMarshallingTests, 'callback_owned_boxed'),
                         'requires newer version of GI')
    @unittest.expectedFailure  # bug 722899
    def test_callback_owned_box(self):
        ...

(I think you can stack those decorators)
Comment 12 Mike Gorse 2014-01-27 23:21:03 UTC
Comment on attachment 267258 [details] [review]
Revised test (pygobject version)

Pushed with the suggested annotations added.
Comment 13 Simon Feltman 2014-07-30 05:56:31 UTC
I've verified that some work I'm doing in bug 726999 fixes this issue. There still is the problem mentioned in comment #5 though.