[pulseaudio-tickets] [Bug 56735] New: pa_mainloop_quit() can't make pa_mainloop_run exit

bugzilla-daemon at freedesktop.org bugzilla-daemon at freedesktop.org
Sun Nov 4 03:09:58 PST 2012


https://bugs.freedesktop.org/show_bug.cgi?id=56735

          Priority: medium
            Bug ID: 56735
                CC: lennart at poettering.net
          Assignee: pulseaudio-bugs at lists.freedesktop.org
           Summary: pa_mainloop_quit() can't make pa_mainloop_run exit
        QA Contact: pulseaudio-bugs at lists.freedesktop.org
          Severity: critical
    Classification: Unclassified
                OS: Linux (All)
          Reporter: changyp6 at gmail.com
          Hardware: Other
            Status: NEW
           Version: unspecified
         Component: clients
           Product: PulseAudio

I wrote a recording program using pulseaudio's API. version 2.1
I found that pa_mainloop_quit can't make pa_mainloop_run exit.
I did a little digging on this problem, and I think I have found this bug.

In pa_mainloop_quit, pa_mainloop_wakeup is called to make pa_mainloop_poll
unblocked from select.
However, In pa_mainloop_wakeup, only if m->state == STATE_POLLING,
this wake up signal is sent to pa_mainloop_poll.

In pa_mainloop_poll, checking if m->quit is set and setting m->state to
STATE_POLLING is not protected.

So, in this case, in multi-thread program, it is possible that
Mainloop-thread: pa_mainloop_poll checked m->quit is set to 0, m->state !=
STATE_POLLING
Controlling-thread: pa_mainloop_quit->pa_mainloop_wakeup checked m->state !=
STATE_POLLING, failed sending wake up signal
Mainloop-thread: pa_mainloop_polling set m->state = STATE_POLLING and go on
calling pa_poll, and everything stops here.

There is on solution: pa_mainloop_wakeup doesn't check if m->state ==
STATE_POLLING, it just send wake up signal, so pa_mainloop_polling will receive
this signal
Or protect the m->quit checking and m->state setting section in
pa_mainloop_poll
and protect pa_mainloop_quit with on mutex, make these two API won't run in
mixed way.

To work around this bug, I have to call pa_mainloop_quit multiple times to make
sure pa_mainloop_run is quit.

Hope this bug can be fixed sooner.

-- 
You are receiving this mail because:
You are the QA Contact for the bug.
You are the assignee for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freedesktop.org/archives/pulseaudio-bugs/attachments/20121104/7d9050f1/attachment.html>


More information about the pulseaudio-bugs mailing list