mirror of
https://gitlab.freedesktop.org/pulseaudio/pulseaudio.git
synced 2025-11-11 13:30:02 -05:00
Fix undefined behaviour in pulseaudio --start.
Don't call pthread_join() to join a thread from a different process than the thread was created in. Doing so can lead to undefined behaviour. On OpenBSD, the symptom was a pulseaudio process with a single thread waiting forever for other threads to join. Since that process also held the autospawn lock, starting new pulseaudio processes with --start kept failing. The problem was analyzed with help from Philip Guenther. This patch adds a pa_thread_free_nojoin() function which can be used to free resources for a thread without a join, as suggested by Tanu Kaskinen. See https://bugs.freedesktop.org/show_bug.cgi?id=71738
This commit is contained in:
parent
303cff04eb
commit
d8e2b3a78c
3 changed files with 16 additions and 1 deletions
|
|
@ -114,8 +114,15 @@ static void unref(bool after_fork) {
|
|||
if (n_ref > 0)
|
||||
return;
|
||||
|
||||
/* Join threads only in the process the new thread was created in
|
||||
* to avoid undefined behaviour.
|
||||
* POSIX.1-2008 XSH 2.9.2 Thread IDs: "applications should only assume
|
||||
* that thread IDs are usable and unique within a single process." */
|
||||
if (thread) {
|
||||
pa_thread_free(thread);
|
||||
if (after_fork)
|
||||
pa_thread_free_nojoin(thread);
|
||||
else
|
||||
pa_thread_free(thread);
|
||||
thread = NULL;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue