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 730138 - gst_bin_add introspection annatation error leads to python resource leak
gst_bin_add introspection annatation error leads to python resource leak
Status: RESOLVED DUPLICATE of bug 702960
Product: GStreamer
Classification: Platform
Component: gstreamer (core)
1.2.3
Other Linux
: Normal normal
: git master
Assigned To: GStreamer Maintainers
GStreamer Maintainers
Depends on:
Blocks: 782499
 
 
Reported: 2014-05-14 16:21 UTC by barry.scott
Modified: 2017-05-11 10:13 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
test script (466 bytes, text/x-python)
2014-05-14 16:21 UTC, barry.scott
  Details
patch to fix annatation problem (472 bytes, patch)
2014-05-14 16:22 UTC, barry.scott
reviewed Details | Review
patch to fix annatation problem v2 (476 bytes, patch)
2014-05-16 10:26 UTC, barry.scott
none Details | Review

Description barry.scott 2014-05-14 16:21:10 UTC
Created attachment 276542 [details]
test script

Using python bindings any element added to a GstBin will be leaked when the bin is disposed of.

It appears that the element is not (transfer full) but should be (transfer none).
This error leads to the pygobject code adding an extra ref to the element that stops it being disposed of.

The attached gst_test.py demonstrates the problem. It pauses to allow you to look at the /proc/xxx/fd to see how many fd's have been opened.

$ python gst_test.py
init done

[At this point only 3 fds]

e1 <__main__.GstAlsaSink object at 0x133f320 (GstAlsaSink at 0x14cc850)>

[At this point only 5 fds, a socketpair accounts for extra 2]

e1 added to b <__main__.GstAlsaSink object at 0x133f320 (GstAlsaSink at 0x14cc850)> <Bin object at 0x133f2d0 (GstBin at 0x1548030)>

b None

e1 None

[At this point only 5 fds, but it should be 3
the socketpair has not been close as the alsasink has not been disposed of]
Comment 1 barry.scott 2014-05-14 16:22:46 UTC
Created attachment 276543 [details] [review]
patch to fix annatation problem

The attached patch fixes the problem.
Comment 2 Thiago Sousa Santos 2014-05-14 18:52:42 UTC
Review of attachment 276543 [details] [review]:

gst_bin_add is not transfer-none, it indeed takes the reference from the application as it does a g_object_ref_sink on the passed element if it doesn't have a parent yet.

What I think you see on your case is that python bindings actually pass a ref and keep a ref on your variable instead of transforming it to None. If you print e1 after adding it to the bin you will still see that your variable holds a ref to it.

Are you looking at this for any particular reason? Are you having an issue with refcounts?
Comment 3 Thiago Sousa Santos 2014-05-14 19:16:33 UTC
Wait, just found what you mean, after setting e1 to None it still has those fds open.

Will check with gir folks, but it is not a transfer-none, should be either transfer-full or transfer-floating.
Comment 4 Tim-Philipp Müller 2014-05-14 20:25:40 UTC
I'm sure there's a bug about this somewhere already
Comment 5 Tim-Philipp Müller 2014-05-14 20:27:03 UTC
bug #657202
Comment 6 barry.scott 2014-05-15 09:27:40 UTC
The other bug has been hanging around for almost 3 years and is not fixed.

transfer-floating is documented as behaving the same as transfer-none.

If gst_bin_add needs to be transfer-full then the bug is in the pygobject code that adds an additional ref if the argument is transfer-full presumably.
Comment 7 barry.scott 2014-05-16 10:26:34 UTC
Created attachment 276663 [details] [review]
patch to fix annatation problem v2

Changed the patch to use transfer floating as suggested.
Comment 8 Tim-Philipp Müller 2016-06-20 10:52:34 UTC
"transfer floating" *sounds* right if it's supposed to mean that only objects with a floating ref are transfered and others not. This is not how it's described in

  https://wiki.gnome.org/Projects/GObjectIntrospection/Annotations

however. If that's what it means, then the semantics should be described as such. (The fact that it's equivalent to 'none' because bindings do this or that with floating refs is not relevant and shouldn't be relied on in the annotation description IMHO).

So we should wait for someone to clarify that in the wiki before putting this in IMHO.
Comment 9 Sebastian Dröge (slomo) 2017-05-11 10:13:21 UTC
Let's handle that in bug #702960, it's all the same problem.

*** This bug has been marked as a duplicate of bug 702960 ***