pa_threaded_mainloop_signal() deadlocks in while condition

Bug #502992 reported by Iain Buclaw
8
This bug affects 1 person
Affects Status Importance Assigned to Milestone
pulseaudio (Ubuntu)
Undecided
Iain Buclaw

Bug Description

Binary package hint: pulseaudio

This bug regards this patch in pulseaudio:
http://git.0pointer.de/?p=pulseaudio.git;a=commitdiff;h=4f5e2b745ea357e2b5c815ff33a556505a7d1f18

The variable n_waiting_for_accept never gets properly assigned a value, and due to compiler optimisations (allocating bits off RAM and never sets them to 000, rather uses what ever was on the RAM before) has an initial value of ie: 1651076143, *not* 0.

So in the function pa_threaded_mainloop_signal() the condition while (m->n_waiting_for_accept > 0) will never be resolved as -
1) Pulse Audio is waiting for 1651076143 accepts before continuing. and -
2) The Application/Library has sent an accept, but is still waiting for Pulse Audio to respond before it continues.

This patch seemed to be an attempt to resolve it, but bug still persists:
http://pulseaudio.org/ticket/738

ProblemType: Bug
Architecture: i386
ArecordDevices:
 **** List of CAPTURE Hardware Devices ****
 card 0: AudioPCI [Ensoniq AudioPCI], device 0: ES1371/1 [ES1371 DAC2/ADC]
   Subdevices: 1/1
   Subdevice #0: subdevice #0
AudioDevicesInUse:
 USER PID ACCESS COMMAND
 /dev/snd/controlC0: iain 2091 F.... pulseaudio
Card0.Amixer.info:
 Card hw:0 'AudioPCI'/'Ensoniq AudioPCI ENS1371 at 0xb800, irq 18'
   Mixer name : 'Cirrus Logic CS4297A rev 3'
   Components : 'AC97a:43525913'
   Controls : 36
   Simple ctrls : 22
Date: Mon Jan 4 15:12:33 2010
DistroRelease: Ubuntu 9.10
NonfreeKernelModules: nvidia
Package: pulseaudio 1:0.9.19-0ubuntu4
ProcEnviron:
 LANG=en_GB.UTF-8
 SHELL=/bin/bash
ProcVersionSignature: Ubuntu 2.6.31-16.53-generic
SourcePackage: pulseaudio
Uname: Linux 2.6.31-16-generic i686
XsessionErrors:
 (polkit-gnome-authentication-agent-1:2063): GLib-CRITICAL **: g_once_init_leave: assertion `initialization_value != 0' failed
 (firefox:2734): GLib-WARNING **: g_set_prgname() called multiple times

Revision history for this message
Iain Buclaw (iainb) wrote :
Revision history for this message
Iain Buclaw (iainb) wrote :

This mostly affects games using the libopenal1 library, and is likely to occur either:
1) When the sound initialises. or -
2) When the sound deinitialises.

But will likely affect any other application that uses Pulse Audio's threaded mainloop library.

Attached is a strace of running Alien Arena 7.33

Note the bottom:

open("/dev/urandom", O_RDONLY|O_NOCTTY|O_LARGEFILE) = 7
read(7, "\351f \257", 4) = 4
close(7) = 0
open("/dev/shm/pulse-shm-2938136297", O_RDWR|O_CREAT|O_EXCL|O_NOFOLLOW|O_CLOEXEC, 0400) = 7
ftruncate64(7, 67108904) = 0
mmap2(NULL, 67112960, PROT_READ|PROT_WRITE, MAP_SHARED, 7, 0) = 0xb36e6000
close(7) = 0
futex(0xdf7c124, FUTEX_WAIT_PRIVATE, 1, NULL <unfinished ...>

Revision history for this message
Iain Buclaw (iainb) wrote :

This mostly affects games using the libopenal1 library, and is likely to occur either:
1) When the sound initialises. or -
2) When the sound deinitialises.

But will likely affect any other application that uses Pulse Audio's threaded mainloop library.

Attached is a strace of running Alien Arena 7.33

Note the bottom:

open("/dev/urandom", O_RDONLY|O_NOCTTY|O_LARGEFILE) = 7
read(7, "\351f \257", 4) = 4
close(7) = 0
open("/dev/shm/pulse-shm-2938136297", O_RDWR|O_CREAT|O_EXCL|O_NOFOLLOW|O_CLOEXEC, 0400) = 7
ftruncate64(7, 67108904) = 0
mmap2(NULL, 67112960, PROT_READ|PROT_WRITE, MAP_SHARED, 7, 0) = 0xb36e6000
close(7) = 0
futex(0xdf7c124, FUTEX_WAIT_PRIVATE, 1, NULL <unfinished ...>

Revision history for this message
Iain Buclaw (iainb) wrote :

The fix is to assign m->n_waiting_for_accept = 0; in the pa_threaded_mainloop_new() function.

Patch supplied.

Regards
Iain

Changed in pulseaudio (Ubuntu):
assignee: nobody → Iain Bucław (tinivole)
Iain Buclaw (iainb)
Changed in pulseaudio (Ubuntu):
status: New → Confirmed
Iain Buclaw (iainb)
description: updated
Revision history for this message
Luke Yelavich (themuso) wrote : Re: [Bug 502992] Re: pa_threaded_mainloop_signal() deadlocks in while condition

Hi Ian, thanks for your report.
I will look at your patch shortly, but might I suggest you also send this to the upstream pulseaudio developers, either directly, or on the mailing list? By sending the patch upstream, everyone accross all distros using pulseaudio can benefit from your bug fix. You can find the upstream maintainer's details on pulseaudio.org.

Thanks

Luke

Revision history for this message
Daniel T Chen (crimsun) wrote : Re: [Bug 502992] Re: pa_threaded_mainloop_signal() deadlocks in while condition

I've submitted this patch upstream.

Revision history for this message
Launchpad Janitor (janitor) wrote :

This bug was fixed in the package pulseaudio - 1:0.9.21-0ubuntu6

---------------
pulseaudio (1:0.9.21-0ubuntu6) lucid; urgency=low

  * Backport fix from master HEAD:
    + 0061-Backport-c5fdb.patch (LP: #502992)
  * The following patches have been merged upstream, but we'll continue
    to apply them here until the next upstream snapshot:
    . 0056-ignore-sound-class-modem.patch
    . 0060-fix-implicit-func-decl-cpu-arm.patch
 -- Daniel T Chen <email address hidden> Tue, 05 Jan 2010 18:34:40 -0500

Changed in pulseaudio (Ubuntu):
status: Confirmed → Fix Released
To post a comment you must log in.
This report contains Public information  Edit
Everyone can see this information.

Other bug subscribers