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 108263 - Possible race condition in gstqueue.c
Possible race condition in gstqueue.c
Status: RESOLVED NOTABUG
Product: GStreamer
Classification: Platform
Component: gstreamer (core)
0.6.0
Other All
: Normal minor
: 0.6.x
Assigned To: GStreamer Maintainers
GStreamer Maintainers
Depends on:
Blocks:
 
 
Reported: 2003-03-13 04:20 UTC by janzen
Modified: 2004-12-22 21:47 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
Patch for unlikely race condition in gstqueue.c (1.74 KB, patch)
2003-03-13 04:21 UTC, janzen
none Details | Review

Description janzen 2003-03-13 04:20:38 UTC
In gstqueue.c, there appears to be the potential for a (highly unlikely,
but not impossible) race condition in the gst_queue_chain() method when
checking the 'flush' variable on a full queue:

      if (queue->interrupt) {
        GST_DEBUG_ELEMENT (GST_CAT_DATAFLOW, queue, "interrupted!!");
        g_mutex_unlock (queue->qlock);
	if (gst_scheduler_interrupt (gst_pad_get_scheduler (queue->sinkpad),
GST_ELEMENT (queue)))
          return;
	/* if we got here bacause we were unlocked after a flush, we don't need
	 * to add the buffer to the queue again */
	if (queue->flush) {
          GST_DEBUG_ELEMENT (GST_CAT_DATAFLOW, queue, "not adding pending
buffer after flush");
	  return;
	}

Note that the 'queue->flush' data member is tested after the mutex is
unlocked.  This should probably be copied to an automatic variable before
the call to g_mutex_unlock(); see the attached patch.
Comment 1 janzen 2003-03-13 04:21:20 UTC
Created attachment 14981 [details] [review]
Patch for unlikely race condition in gstqueue.c
Comment 2 Benjamin Otte (Company) 2003-03-14 17:21:59 UTC
I believe the current behaviour is correct.

Imagine the following scenario:
- The queue is full.
- A new buffer arrives. The chain function returns via 
gst_scheduler_interrupt to let the scheduler go on.
- A flush event arrives on the other side of the queue, the queue is 
emptied.
- The scheduler reschedules the queue, the chain function goes on 
executing. The queue has been flushed, but we're still holding a 
buffer.
In this case the buffer should be discarded and not put into the 
queue, which is exactly what is done.


As a sidenote:
We're missing a lot of gst_buffer_unref's when returning from 
erroneous behaviour.
Comment 3 janzen 2003-03-24 07:48:36 UTC
Makes sense; I agree that this is not, in fact a bug.