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 691499 - g_get_prgname() has wrong introspection mark-up
g_get_prgname() has wrong introspection mark-up
Status: RESOLVED FIXED
Product: gobject-introspection
Classification: Platform
Component: general
2.35.x
Other Linux
: Normal normal
: ---
Assigned To: gobject-introspection Maintainer(s)
gobject-introspection Maintainer(s)
Depends on:
Blocks:
 
 
Reported: 2013-01-10 21:24 UTC by Mike Gorse
Modified: 2015-02-07 17:01 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
Patch. (1.53 KB, patch)
2013-01-10 21:29 UTC, Mike Gorse
committed Details | Review

Description Mike Gorse 2013-01-10 21:24:05 UTC
When gobject-introspection parses glib's headers, it decides that g_get_prgname() should be marked as transfer full, so, ie, pygobject frees the value returned from it when it should not. I think that this could be fixed through introspection mark-up, but it seems to me that the correct thing to do would be to prototype the function as returning a const value, since it returns a string that is owned by glib. This would have the side-effect of making g-ir-scanner assume that the return value is not owned by the caller.
Comment 1 Mike Gorse 2013-01-10 21:29:06 UTC
Created attachment 233183 [details] [review]
Patch.
Comment 2 Colin Walters 2013-01-11 13:12:51 UTC
Review of attachment 233183 [details] [review]:

This is clearly correct, but does it break the C++ bindings?  danw?
Comment 3 Dan Winship 2013-01-11 14:15:10 UTC
(IANA C++ expert, this is just something I have a mental note to be paranoid about. Anyway...)

As I understand it, changes made to C headers won't *directly* break C++, because they're all inside G_BEGIN_DECLS aka extern "C". But if glibmm translates the C signatures into C++ wrappers in a way that the change would be exposed in C++ as well, then it does break things.

In this case, it looks like all of those gutils.h functions return "std::string" in glibmm, regardless of whether they have "const" or not, so it seems like it *should* be ok...


Ignoring C++ though, this will cause compile failures for C code that does "char *foo = g_get_prgname ();" and uses certain -Werror options...
Comment 4 Colin Walters 2013-01-11 14:20:57 UTC
(In reply to comment #3)

> In this case, it looks like all of those gutils.h functions return
> "std::string" in glibmm, regardless of whether they have "const" or not, so it
> seems like it *should* be ok...

Ah, ok.
 
> Ignoring C++ though, this will cause compile failures for C code that does
> "char *foo = g_get_prgname ();" and uses certain -Werror options...

Yeah...that is a concern, but IIRC we also have other precedents for changes like this?
Comment 5 Matthias Clasen 2013-01-12 17:57:08 UTC
So far, I found:

gdk-pixbuf:

queryloaders.c: In function ‘main’:
queryloaders.c:333:17: warning: assignment discards ‘const’ qualifier from pointer target type [enabled by default]

at-spi2-atk:

registry.c:380:14: warning: assignment discards ‘const’ qualifier from pointer target type [enabled by default]

gtk:

gtktoplevelaccessible.c: In function 'gtk_toplevel_accessible_initialize':
gtktoplevelaccessible.c:47:20: warning: assignment discards 'const' qualifier from pointer target type [enabled by default]

vala:

scanner.c:235:25: warning: assignment discards ‘const’ qualifier from pointer target type [enabled by default]
Comment 6 Matthias Clasen 2013-01-12 17:57:43 UTC
I think we could try to add the const in the next devel release and see how big the fallout is.
Comment 7 Colin Walters 2013-01-13 17:36:20 UTC
Comment on attachment 233183 [details] [review]
Patch.

This was committed by Benjamin:

http://git.gnome.org/browse/glib/commit/?id=120834db5b1cc735530d2452440ffd8a3b6e48f7

I guess at this point let's just go with it.
Comment 8 Benjamin Otte (Company) 2013-01-13 17:38:41 UTC
Sorry I wasn't aware of the bug, I just had IRC discussions with Mike and Ryan about it. And we decided to go with it in there.
Comment 9 Colin Walters 2013-01-13 17:47:12 UTC
gdk-pixbuf: http://git.gnome.org/browse/gdk-pixbuf/commit/?id=516d5e0eee263bb311df1e081f4912e313788982

I couldn't find a call to g_get_prgname() in at-spi2-atk (or at-spi2-core).

gtk3 looks OK from a quick code inspection.

Will clone this bug for vala.
Comment 10 Colin Walters 2013-01-13 17:49:24 UTC
Jürg, can you look at updating vala for this?
Comment 11 Jürg Billeter 2013-01-13 19:28:19 UTC
(In reply to comment #10)
> Jürg, can you look at updating vala for this?

scanner.c in vala (from old g-i) doesn't use g_get_prgname, the warning mentioned above is not related to this bug.

Vala applications are not affected either, as the manual GLib bindings have correct ownership information.
Comment 12 André Klapper 2015-02-07 17:01:32 UTC
[Mass-moving gobject-introspection tickets to its own Bugzilla product - see bug 708029. Mass-filter your bugmail for this message: introspection20150207 ]