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 673282 - girepository: g_object_info_get_*_function_pointer() is completely broken
girepository: g_object_info_get_*_function_pointer() is completely broken
Status: RESOLVED FIXED
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: 2012-04-01 06:47 UTC by Pavel Holejsovsky
Modified: 2015-02-07 17:02 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
Avoid _get_func() consuming reference from input info (1.33 KB, patch)
2012-04-01 06:47 UTC, Pavel Holejsovsky
none Details | Review
Avoid _get_func() consuming reference from input info (2.34 KB, patch)
2012-04-07 16:17 UTC, Pavel Holejsovsky
committed Details | Review

Description Pavel Holejsovsky 2012-04-01 06:47:13 UTC
g_object_info_get_*_function() family of functions is completely broken because of bugs in underlying _get_func() implementation.  See attached patch with description and fix.
Comment 1 Pavel Holejsovsky 2012-04-01 06:47:16 UTC
Created attachment 211064 [details] [review]
Avoid _get_func() consuming reference from input info

Fix of leak in 4c9424e18d71237f438a99bc5f2d45ae7de60b78 was a bit
overaggressive, stealing also one reference from input 'info'
argument.

Also fixes another bug in that commit - local 'func' shadowing the
return value, causing that function always returned NULL even when
some result was actually found.
Comment 2 Johan (not receiving bugmail) Dahlin 2012-04-06 13:11:51 UTC
Review of attachment 211064 [details] [review]:

This would be far easier to review if there were a test case included. Is it possible to write one?
Comment 3 Pavel Holejsovsky 2012-04-06 13:21:38 UTC
Probably yes, but I don't think that it would be informative for the review.  The testcase is:

GIBaseInfo *info;
info = g_irepository_find_by_name(NULL, "Regress", "TestFundamentalObject");
gpointer func = g_object_info_get_ref_function_pointer (info);
assert (info != NULL);
g_base_info_unref (info);

1. failing at assert() 
2. even if assert is commented out, crashing later in g_base_info_unref(), because g_object_info_get_ref_function_pointer() already stole the last reference from the info.

I'm a bit out of time now, I can try to add proper patch with integrated testcase during the weekend, if needed.
Comment 4 Pavel Holejsovsky 2012-04-06 13:23:15 UTC
(In reply to comment #3)
> GIBaseInfo *info;
> info = g_irepository_find_by_name(NULL, "Regress", "TestFundamentalObject");
> gpointer func = g_object_info_get_ref_function_pointer (info);
> assert (info != NULL);
> g_base_info_unref (info);

oops, mistake;

assert (func != NULL);
Comment 5 Pavel Holejsovsky 2012-04-07 16:17:47 UTC
Created attachment 211544 [details] [review]
Avoid _get_func() consuming reference from input info

Another version of the patch, contains simple test which crashes
when the fix is not applied.
Comment 6 Johan (not receiving bugmail) Dahlin 2012-04-08 12:22:10 UTC
Review of attachment 211544 [details] [review]:

Perfect, thanks.
Comment 7 Pavel Holejsovsky 2012-04-08 17:55:34 UTC
I suggest to include this patch also to 3_4 branch, this bug is
regression from GI 1.30

Attachment 211544 [details] pushed as 5fda6c3 - Avoid _get_func() consuming reference from input info
Comment 8 André Klapper 2015-02-07 17:02:55 UTC
[Mass-moving gobject-introspection tickets to its own Bugzilla product - see bug 708029. Mass-filter your bugmail for this message: introspection20150207 ]