Releasing a mutex twice on EOS in gstaudiobasesink
While triaging another locking issue a come across the code where we can unlocking mutex twice (which is UB) in gstaudiobasesink.c:2350:
static void
gst_audio_base_sink_callback (GstAudioRingBuffer * rbuf, guint8 * data,
guint len, gpointer user_data)
{
...
GST_PAD_STREAM_LOCK (basesink->sinkpad);
...
eos:
{
/* FIXME: this is not quite correct; we'll be called endlessly until
* the sink gets shut down; maybe we should set a flag somewhere, or
* set segment.stop and segment.duration to the last sample or so */
GST_DEBUG_OBJECT (sink, "EOS");
gst_audio_base_sink_drain (sink);
gst_audio_ring_buffer_pause (rbuf);
gst_element_post_message (GST_ELEMENT_CAST (sink),
gst_message_new_eos (GST_OBJECT_CAST (sink)));
GST_PAD_STREAM_UNLOCK (basesink->sinkpad); <--- First unlock
<--- Missing `return;`?
}
flushing:
{
GST_DEBUG_OBJECT (sink, "we are flushing");
gst_audio_ring_buffer_pause (rbuf);
GST_BASE_SINK_PREROLL_UNLOCK (basesink); <--- Unlock the lock which is not locked
GST_PAD_STREAM_UNLOCK (basesink->sinkpad); <--- Second unlock
return;
}
...
}
Most probably there is a missing return;
on line 2350.
This issue is not affecting us but just wanted to let you about it.