[Bug 727100] v4l2bufferpool: Race condition on qbuf/dqbuf in a multithreaded context

GStreamer (bugzilla.gnome.org) bugzilla at gnome.org
Wed May 14 05:25:40 PDT 2014


https://bugzilla.gnome.org/show_bug.cgi?id=727100
  GStreamer | gst-plugins-good | 1.2.3

Aurélien Zanelli <aurelien.zanelli> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |aurelien.zanelli at parrot.com

--- Comment #13 from Aurélien Zanelli <aurelien.zanelli at parrot.com> 2014-05-14 12:25:37 UTC ---
(In reply to comment #12)
> Looking at that race, couldn't we solve this lock less, by setting the queue
> buffer before calling qbuf ? The ioctl is good synchronization by itself.

Since device is open in blocking mode, I think it should do the job in this
case, ie when we are blocked in DQBUF ioctl

However I'm thinking about another scenario: we have two threads: first which
qbuf one buffer and second which will dqbuf another buffer.
So we have:

      Thread 1                         Thread 2
gst_qbuf(pool, buf1)           gst_dqbuf(pool, buf2)
       |                                 |
       |                                 |
pool->buffers[1] = buf1              |
pool->num_queued++                       |
                               ioctl(DQBUF)
                               outbuf = pool->buffers[2]
                               pool->buffers[2] = NULL
                               pool->num_queued--;
ioctl(QBUF)                              |           


Result could be an inconsistent pool->num_queued due to the fact that 
pool->num_queued++ may not be atomic if Thread 2 is executed just after Thread
1 fetch the value of pool->num_queued.

Nevertheless, this case could be related with the fact that in 1.2,
v4l2bufferpool is not really thread-safe.

-- 
Configure bugmail: https://bugzilla.gnome.org/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the QA contact for the bug.
You are the assignee for the bug.


More information about the gstreamer-bugs mailing list