Quantcast

Pipeline crashing when unrefing samples

classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Pipeline crashing when unrefing samples

mizerb
Hello!
Hoping someone more experienced then me might be able to take a look at this.

I'm writting a app that renders frames I'm taking from an appsink, which in turn is connected to a playbin.

At the moment, the application works, but has a memory leak from when I'm creating samples via

Gst* sample = gst_app_sink_try_pull_sample(mysink, timeout_cont);

However, once I'ved copied my data out from the buffer I get from the sample, if I try to delete the sample

gst_sample_unref(sample);

The pipeline crashes with the errors on the bus:
Error received from element multiqueue9: Internal data stream error.
Debugging information: gstmultiqueue.c(2029): gst_multi_queue_loop (): /GstPlayBin:playbin0/GstURIDecodeBin:uridecodebin0/GstDecodeBin:decodebin2/GstMultiQueue:multiqueue9:
streaming stopped, reason error (-5)

If I try launching the pipleline with videotestsrc I run into errors as well (trying to find the error messages but it was something with videosrcbase if I'm remembering)

Is gstreamer doing something I don't know about with samples after I've pulled them down? Are samples not static for use? Does Gstreamer require the data there for continued use of the pipeline after it's been passed out of playbin?

Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Pipeline crashing when unrefing samples

Tim Müller
On Fri, 2017-02-10 at 14:14 -0800, mizerb wrote:

Hi,

> At the moment, the application works, but has a memory leak from when
> I'm creating samples via 
>
> Gst* sample = gst_app_sink_try_pull_sample(mysink, timeout_cont);
>
> However, once I'ved copied my data out from the buffer I get from the
> sample, if I try to delete the sample 
>
> gst_sample_unref(sample);
>
> The pipeline crashes with the errors on the bus: (snip)

This happens even if all you do is pull_sample() + sample_unref() and
nothing else?

Cheers
 -Tim
--
Tim Müller, Centricular Ltd - http://www.centricular.com
_______________________________________________
gstreamer-devel mailing list
[hidden email]
https://lists.freedesktop.org/mailman/listinfo/gstreamer-devel
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Pipeline crashing when unrefing samples

mizerb
Tim,
Thank you for responding! Hadn't thought check it without the gst_buffer calls.

Tim Müller wrote
This happens even if all you do is pull_sample() + sample_unref() and
nothing else?
Well, no. I'm pulling the buffer from the sample, and digging in, the call to

gst_buffer_unref(buffer);

causes the failure. Even while skipping out on the map and unmap calls. However, if i don't unref the sample, then unref on the buffer doesn't cause the issue to crop up. So it seems I can unref either the sample or the buffer, but not both.

Also, the unrefing the buffer causes the error:

 Error received from element hlsdemux2: Internal data stream error.
Debugging information: gstadaptivedemux.c(2256): _src_chain (): /GstPlayBin:playbin0/GstURIDecodeBin:uridecodebin0/GstDecodeBin:decodebin2/GstHLSDemux:hlsdemux2:
streaming stopped, reason error (-5)


Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Pipeline crashing when unrefing samples

Tim Müller
On Mon, 2017-02-13 at 03:44 -0800, mizerb wrote:

Hi,

> Well, no. I'm pulling the buffer from the sample, and digging in, the
> call to 
>
> gst_buffer_unref(buffer);
>
> causes the failure. Even while skipping out on the map and unmap
> calls. However, if i don't unref the sample, then unref on the buffer
> doesn't cause the issue to crop up. So it seems I can unref either
> the sample or the buffer, but not both. 

The buffer "belongs" to the sample. You get a ref to the sample, and
you should unref the sample when you're done with it. When the sample
gets freed, it will free the buffer.

You must not unref the sample's buffer unless you explicitly took a ref
to it previously to acquire a ref of your own.

Similarly, you must also acquire a ref of your own before
gst_app_src_push-ing the buffer into appsrc, since appsrc takes
ownership of it (just in case that's what you plan on doing with it).


> Also, the unrefing the buffer causes the error:
>  (snip)

That's just luck. It might also just crash or cause other weird
failures :)

Cheers
 -Tim

--
Tim Müller, Centricular Ltd - http://www.centricular.com
_______________________________________________
gstreamer-devel mailing list
[hidden email]
https://lists.freedesktop.org/mailman/listinfo/gstreamer-devel
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Pipeline crashing when unrefing samples

mizerb
Tim,
That fixed it. Thank you so much! And that patched the leak too.
Loading...