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 640542 - matroskamux leaks memory after reset
matroskamux leaks memory after reset
Status: RESOLVED FIXED
Product: GStreamer
Classification: Platform
Component: gst-plugins-good
0.10.24
Other Linux
: Normal normal
: 0.10.29
Assigned To: GStreamer Maintainers
GStreamer Maintainers
Depends on:
Blocks:
 
 
Reported: 2011-01-25 13:53 UTC by Ognyan Tonchev (redstar_)
Modified: 2011-03-08 15:31 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
unit test which triggers the leak (2.42 KB, patch)
2011-01-25 13:53 UTC, Ognyan Tonchev (redstar_)
none Details | Review

Description Ognyan Tonchev (redstar_) 2011-01-25 13:53:24 UTC
Created attachment 179290 [details] [review]
unit test which triggers the leak

The muxer will leak the ebml_write->caps after reset. I've seen the problem in plugins-good 0.10.24 but i am pretty sure it also exists in the latest version of the muxer.

The easiest way to reproduce the leak is:

gst_element_state (pipe, GST_STATE_PLAY);
gst_element_state (pipe, GST_STATE_NULL);
gst_element_state (pipe, GST_STATE_PLAY);

and gst_matroska_mux_start () will create new caps without unreffing the old caps. The suggested fix is to unref the caps in gst_ebml_write_reset ():

void
gst_ebml_write_reset (GstEbmlWrite * ebml)
{
  ebml->pos = 0;

  if (ebml->cache) {
    gst_byte_writer_free (ebml->cache);
    ebml->cache = NULL;
  }

  if (ebml->caps) {
    gst_caps_unref (ebml->caps);
    ebml->caps = NULL;
  }

  ebml->last_write_result = GST_FLOW_OK;
  ebml->timestamp = GST_CLOCK_TIME_NONE;
  ebml->need_newsegment = TRUE;
}

Attached is also a unit test which triggers the problem.
Comment 1 Tim-Philipp Müller 2011-01-26 08:53:44 UTC
Thanks, should be fixed now (a patch in git format-patch format would be appreciated next time):

 commit 0add79cbf1612b8a3cdcb8ea0ad41f1e6059282e
 Author: Ognyan Tonchev <ognyan.tonchev@axis.com>
 Date:   Wed Jan 26 08:48:43 2011 +0000

    matroskamux: don't leak ebml writer caps when re-using matroskamux
    
    https://bugzilla.gnome.org/show_bug.cgi?id=640542