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 747990 - bin/element: gst_bin_add() and gst_element_add_pad() don't take reference in error cases
bin/element: gst_bin_add() and gst_element_add_pad() don't take reference in ...
Status: RESOLVED FIXED
Product: GStreamer
Classification: Platform
Component: gstreamer (core)
git master
Other Linux
: Normal normal
: 1.13.1
Assigned To: GStreamer Maintainers
GStreamer Maintainers
: 752206 (view as bug list)
Depends on:
Blocks: 782499
 
 
Reported: 2015-04-16 11:42 UTC by Sebastian Dröge (slomo)
Modified: 2017-05-17 12:32 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
fix pad memory leak (1.09 KB, patch)
2015-07-10 07:57 UTC, Vineeth
none Details | Review
bin: fix element leak (784 bytes, patch)
2015-07-10 07:58 UTC, Vineeth
none Details | Review
bin: fix element leak (822 bytes, patch)
2015-07-10 08:42 UTC, Vineeth
none Details | Review
element: fix pad leak (1.15 KB, patch)
2015-07-10 08:42 UTC, Vineeth
committed Details | Review
bin:fix element leak (1.29 KB, patch)
2015-07-10 14:02 UTC, Vineeth
committed Details | Review
object: remove floating reference of object (889 bytes, patch)
2015-07-13 01:57 UTC, Vineeth
committed Details | Review
gst: Fix floating reference inconsistencies in error cases (2.47 KB, patch)
2017-05-15 11:37 UTC, Sebastian Dröge (slomo)
committed Details | Review
gst: Handle floating references consistently (3.72 KB, patch)
2017-05-15 11:37 UTC, Sebastian Dröge (slomo)
committed Details | Review

Description Sebastian Dröge (slomo) 2015-04-16 11:42:52 UTC
In all error cases they just return FALSE but don't unref the element/pad. Also they give a g_critical() or g_warning().


For bindings that's never going to work, it must be consistent with the annotations always :)
Comment 1 Sebastian Dröge (slomo) 2015-07-10 07:49:43 UTC
*** Bug 752206 has been marked as a duplicate of this bug. ***
Comment 2 Vineeth 2015-07-10 07:57:51 UTC
Created attachment 307201 [details] [review]
fix pad memory leak
Comment 3 Vineeth 2015-07-10 07:58:14 UTC
Created attachment 307202 [details] [review]
bin: fix element leak
Comment 4 Sebastian Dröge (slomo) 2015-07-10 08:07:31 UTC
Comment on attachment 307202 [details] [review]
bin: fix element leak

I'm not sure this is entirely correct because of floating references. I think it should call gst_object_ref_sink() (somewhere, if it doesn't already. gst_object_set_parent() does that IIRC) and only then gst_object_unref(). For both patches.
Comment 5 Vineeth 2015-07-10 08:42:32 UTC
Created attachment 307204 [details] [review]
bin: fix element leak
Comment 6 Vineeth 2015-07-10 08:42:54 UTC
Created attachment 307205 [details] [review]
element: fix pad leak
Comment 7 Sebastian Dröge (slomo) 2015-07-10 09:10:57 UTC
Comment on attachment 307204 [details] [review]
bin: fix element leak

You also need to do the same in gst_bin_add_func()
Comment 8 Sebastian Dröge (slomo) 2015-07-10 09:12:54 UTC
Comment on attachment 307205 [details] [review]
element: fix pad leak

For the had_parent case, I think gst_object_set_parent() is not behaving correct
Comment 9 Vineeth 2015-07-10 14:02:32 UTC
Created attachment 307228 [details] [review]
bin:fix element leak

fix element leak for error cases in
gst_bin_add_func and gst_bin_add


For element, i guess the changes are ok for the time being, until we decide on the removal of floating references.
Comment 10 Vineeth 2015-07-13 01:57:43 UTC
Created attachment 307325 [details] [review]
object: remove floating reference of object

removing floating reference of the object when parent is already present for the object.
By doing this here, each caller of this function need not remove the floating reference when this function fails.
If this change is accepted, then the other two patches need to be changed such that in case of had_parent, there is no need to remove floating point references.
Comment 11 Vineeth 2015-07-21 10:48:00 UTC
Sebastian, anything else needs to be done for this?
Comment 12 Hyunjun Ko 2015-07-31 04:15:22 UTC
Vineeth.
For the had_parent case, I guess, you don't need to call ref_sink.
Because had_parent means that this object is already converted to normal

And I'm not sure whether it should call unref for had_parent case.
Because it also means that this object is owned by someone else.
Comment 13 Sebastian Dröge (slomo) 2017-05-11 07:45:33 UTC
More cases here that are inconsistent: https://bugzilla.gnome.org/show_bug.cgi?id=702960#c25
Comment 14 Vineeth 2017-05-12 03:02:58 UTC
Hi Sebastian,
I am not working on Gstreamer anymore..
Sorry about the incomplete fix..
Can you please proceed with the fix..
Comment 15 Sebastian Dröge (slomo) 2017-05-12 07:01:42 UTC
Sure, no problem at all Vineeth :) Thanks for letting me know
Comment 16 Sebastian Dröge (slomo) 2017-05-15 11:37:05 UTC
Created attachment 351880 [details] [review]
gst: Fix floating reference inconsistencies in error cases

If a function takes a floating reference and sinks it, it should also do
that in error cases. I.e. call ref_sink() followed by unref().

Otherwise the reference counting behaviour of the function will be
different between the good and the error case, and simply inconsistent.
Comment 17 Sebastian Dröge (slomo) 2017-05-15 11:37:21 UTC
Created attachment 351881 [details] [review]
gst: Handle floating references consistently

If a function takes a floating reference parameter, it should also be
sinked in error cases. Otherwise the function behaves differently
between error and normal cases, which is impossible for bindings to
handle.
Comment 18 Sebastian Dröge (slomo) 2017-05-17 12:28:31 UTC
Attachment 351880 [details] pushed as 7c4d3a6 - gst: Fix floating reference inconsistencies in error cases
Attachment 351881 [details] pushed as 2e4c82d - gst: Handle floating references consistently