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 747431 - gobject-introspection should annotate pointer plus GDestroyNotify, e.g. in g_memory_input_stream_new_from_data()
gobject-introspection should annotate pointer plus GDestroyNotify, e.g. in g_...
Status: RESOLVED OBSOLETE
Product: gobject-introspection
Classification: Platform
Component: general
unspecified
Other All
: Normal normal
: ---
Assigned To: gobject-introspection Maintainer(s)
gobject-introspection Maintainer(s)
Depends on:
Blocks:
 
 
Reported: 2015-04-07 02:29 UTC by Philip Chimento
Modified: 2018-02-08 12:34 UTC
See Also:
GNOME target: ---
GNOME version: ---



Description Philip Chimento 2015-04-07 02:29:49 UTC
Consider the following GJS program:

const Gio = imports.gi.Gio;
let stream = Gio.MemoryInputStream.new_from_data('', -1, null);

This segfaults. I believe it's because GJS frees the string data before freeing the GMemoryInputStream at the end of the program. PyGObject seems to copy the data and doesn't segfault.

However, I don't think it's possible to properly use this function in introspected bindings; really, no-one should have to pass in a GDestroyNotify to introspected API. (This was kind of a side effect of https://bugzilla.gnome.org/show_bug.cgi?id=589887 which was eventually closed with no changes.) And there's really no sensible value to pass besides NULL.

Now that we have g_memory_input_stream_new_from_bytes() I think ..._new_from_data() should be annotated with (skip).
Comment 1 Philip Withnall 2017-08-23 12:49:19 UTC
Ideally, the bindings should be able to hide the `destroy` parameter and set its value to whatever is most convenient for their memory handling. However, I don’t think there’s a way to represent that in introspection annotations at the moment — annotations like (destroy) and (scope) are only relevant with respect to callback arguments.

I think the fix here is to expand the set of supported annotations to cover this pattern (passing a pointer plus a GDestroyNotify for it, without any associated callback) rather than to skip g_memory_input_stream_new_from_data().
Comment 2 Philip Chimento 2017-08-25 03:45:43 UTC
OK, I buy that. Updated title and component accordingly.
Comment 3 Philip Withnall 2017-09-08 13:59:23 UTC
(In reply to Philip Chimento from comment #2)
> OK, I buy that. Updated title and component accordingly.

Thanks. Are you planning on working on this? Since it would be introducing a new introspection annotation, it’s something which should be discussed on the mailing list (https://mail.gnome.org/mailman/listinfo/gir-devel-list).
Comment 4 Philip Chimento 2017-09-12 02:45:54 UTC
I didn't have any plans for this.
Comment 5 GNOME Infrastructure Team 2018-02-08 12:34:00 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/gobject-introspection/issues/129.