GNOME Bugzilla – Bug 574024
[GstAdapter] gst_adapter_push should not accept empty buffers
Last modified: 2009-03-04 08:25:30 UTC
Please describe the problem: When empty buffers are pushed into an adapter, these buffers remain alive until gst_adapter_clear is called. This can potentially be a runtime leak in filters which access adapters with take, peek and flush functions, and only clear the adapter in their reset or finalize functions. For a live streaming application, this can cause the adapter to grow indefinitely. Steps to reproduce: I stumbled on this problem by doing some tests with the fakesrc filter. For instance, the following pipeline causes a major leak which can quickly use up all available memory : gst-launch-0.10 fakesrc ! mpegtsdemux ! fakesink I recommand using ulimit to prevent a DoS while running this, or be quick to kill it ;-) Actual results: fakesrc pushes buffers with no data, mpegtsdemux adds these buffers to it's initial adapter then checks for available size. Since all buffers are empty, the adapter just keeps growing. If subsequent buffers are not empty and regular take and peek functions are called, the empty buffers are ignored and remain queued in the adapter. Expected results: Does this happen every time? Yes it's systematic Other information: I'm not sure about the odds of encountering empty buffers, but seeing the udpsrc filter allows receiving empty payloads, I guess it's plausible. In any case, I think it's conceptually wrong to pile up empty buffers in an adapter for which the purpose is to provide a fixed number of bytes. These should be unreffed automatically in the gst_adapter_push function.
Indeed, since the adapter works in bytes, pushing empty buffers is pointless. They should be unreffed in _push().
commit f0481cb7174008336f16a9ea7b45c1ae5d197cf4 Author: Edward Hervey <bilboed@bilboed.com> Date: Wed Mar 4 09:20:43 2009 +0100 GstAdapter: Discard empty buffers in _push(). Fixes #574024