Commit 53538ff9 authored by Bartosz Golaszewski's avatar Bartosz Golaszewski
Browse files

PulseAudio: fix a pthread_mutex crash in error path


QSoundEffect (pulseaudio) uses a workaround for stability issues:
although the pulseaudio mainloop mutex is recursive, it utilizes a
separate lock counting. This is not the best solution, but it is a
part of a larger set of changes which improved the stability in CI
under heavy load.

QSoundEffect always calls pa_threaded_mainloop_lock/unlock() from the
same thread so the additional lock counting works in normal situation
even though it doesn't use atomic types.

However if pa_context_connect() fails, pa_threaded_mainloop_unlock()
is called without regard to current lock count. This leads to random
double-unlock aborts if pa_context_connect() fails more than once
(e.g. after the reconnect scheduled from onContextFailed()).

Fix this by always using the PulseDaemon wrappers around
pa_threaded_mainloop_lock/unlock().

Task-number: QTBUG-61725
Change-Id: I41eb9a76892a6646fd5620ef8f686473b339464f
Reviewed-by: default avatarChristian Stromme <christian.stromme@qt.io>
parent 2b343aff
Branches
Tags
No related merge requests found
Showing with 2 additions and 2 deletions
......@@ -181,7 +181,7 @@ private Q_SLOTS:
if (m_context == 0) {
qWarning("PulseAudioService: Unable to create new pulseaudio context");
pa_threaded_mainloop_unlock(m_mainLoop);
unlock();
pa_threaded_mainloop_free(m_mainLoop);
m_mainLoop = 0;
onContextFailed();
......@@ -193,7 +193,7 @@ private Q_SLOTS:
if (pa_context_connect(m_context, 0, (pa_context_flags_t)0, 0) < 0) {
qWarning("PulseAudioService: pa_context_connect() failed");
pa_context_unref(m_context);
pa_threaded_mainloop_unlock(m_mainLoop);
unlock();
pa_threaded_mainloop_free(m_mainLoop);
m_mainLoop = 0;
m_context = 0;
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment