GNOME Bugzilla – Bug 615572
Buffer Leak in audiorate during fill process
Last modified: 2010-04-16 18:52:40 UTC
Created attachment 158532 [details] [review] The patch that fixes the leak mentioned in this issue. Overview: A buffer leak (Memory leak) was detected in the audiorate module when performing a fill operation. When the fill buffer was not successfully pushed (i.e. ret != GST_FLOW_OK) the input buffer is not being unreffed; hence, causing the memory leak mentioned above. Steps to Reproduce: In my case, I was stopping the pipeline a random intervals which the pipeline was processing. This produced the aforementioned leak. Actual Results: The application leaked memory. Expected Results: The application should not leak. Build Date & Platform: git Additional Information: Attached is the patch that fixes this issue.
Comment on attachment 158532 [details] [review] The patch that fixes the leak mentioned in this issue. This doesn't look right at all. gst_pad_push() always takes ownership of the buffer (reference), so unreffing depending on the flow return is definitely wrong. Either the leak is elsewhere in audiorate, or a downstream element doesn't unref the buffer correctly in the case you describe. What elements are downstream of audiorate in your case? Maybe you could add a unit test to tests/check/elements/audiorate.c that demonstrates the problem? Have you tried newer versions of gst-plugins-base? 0.10.20 is a bit old.
I understand that gst_pad_push() always takes ownership of the buffer (reference), but the buffer being pushed in the case of the fill operation is the fill buffer: i.e. ret = gst_pad_push (audiorate->srcpad, fill); not the input buffer to the chain function: gst_audio_rate_chain (GstPad * pad, GstBuffer * buf) and it is the input buffer that leaks in the issue I described since it never gets freed (see the jump to beach). If this does not make sense, or I made a mistake, then let me know and I can always try and put together a unit test or something to demonstrate the problem.
Ah, my apologies, looks like I misread the patch.
Created attachment 158909 [details] [review] audiorate: Don't leak the input buffer in error cases Fixes bug #615572.
Created attachment 158910 [details] [review] audiorate: Don't leak the input buffer in error cases Fixes bug #615572.
(In reply to comment #5) > Created an attachment (id=158910) [details] [review] > audiorate: Don't leak the input buffer in error cases > > Fixes bug #615572. This patch fixes the leak in a different way... there were more places where the buffer would be leaked. Tim, shall I push this for next pre-release?
commit 0a8b8ceda0ee88e6c2b85563a7c1315e4e12b0a6 Author: Sebastian Dröge <sebastian.droege@collabora.co.uk> Date: Fri Apr 16 20:03:21 2010 +0200 audiorate: Don't leak the input buffer in error cases Fixes bug #615572.