pulseaudio: crashes with " asyncmsgq.c: Assertion 'pa_atomic_load(&(a)->_ref) > 0' failed at pulsecore/asyncmsgq.c:176, function pa_asyncmsgq_get()" disconnecting bluetooth audio (A2DP)
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
Raspbian |
New
|
Undecided
|
Unassigned |
Bug Description
Steps to reproduce
0. You'll need a pi3 or bluetooth dongle in an older pi - no desktop. Using 2016-09-
1. Add user pi to system pulseaudio group
$ sudo adduser pi pulse-access
2. start pulseaudio as system service
Firstly add the following lines to /etc/pulse/
load-module module-
load-module module-
Then start as follows to see log details directly
$ sudo pulseaudio --system --realtime --disallow-exit --no-cpu-limit --high-priority -vvvv &
3. Pair with audio device (eg bluetooth headset or speakers)
$ bluetoothctl
[bluetooth]# scan on
[bluetooth]# pair aa:bb:cc:dd:ee:ff
Attempting to pair with aa:bb:cc:dd:ee:ff
[bluetooth]# connect aa:bb:cc:dd:ee:ff
Attempting to connect aa:bb:cc:dd:ee:ff
Connection successful
[bluetooth]# trust aa:bb:cc:dd:ee:ff
[bluetooth]# quit
4. Verify pulseaudio sink set to new bluez device:
$ pactl info
...
Default Sink: bluez_sink.
...
5. From another terminal/ssh: play something - at least a minute long - use aplay or gst123 (eg for mp3)
$ gst123 -z -a pulse=bluez_
6. Ensure you hear audio on the bluetooth device
7. Turn off the bluetooth device without stopping anything on the pi - pulseaudio eventually (~20sec) crashes during the disconnect:
D: [pulseaudio] core-subscribe.c: Dropped redundant event due to change event.
I: [pulseaudio] module-
D: [pulseaudio] module-
D: [pulseaudio] core-subscribe.c: Dropped redundant event due to remove event.
D: [bluetooth] module-
D: [pulseaudio] module-
[Thread 0x7167e3f0 (LWP 3467) exited]
D: [pulseaudio] module-
I: [pulseaudio] bluez5-util.c: Transport /org/bluez/
D: [pulseaudio] module-
I: [pulseaudio] sink.c: Freeing sink 1 "bluez_
I: [pulseaudio] source.c: Freeing source 1 "bluez_
I: [pulseaudio] card.c: Changed profile of card 1 "bluez_
E: [pulseaudio] asyncmsgq.c: Assertion 'pa_atomic_
Here's the GDB stack trace:
Program received signal SIGABRT, Aborted.
0x76bddf70 in __GI_raise (sig=sig@entry=6)
at ../nptl/
56 ../nptl/
(gdb) bt
#0 0x76bddf70 in __GI_raise (sig=sig@entry=6)
at ../nptl/
#1 0x76bdf324 in __GI_abort () at abort.c:89
#2 0x76f131fc in pa_asyncmsgq_get (a=0x76cee094 <lock>, a@entry=0x42ed8,
object=
userdata=
chunk=
at pulsecore/
#3 0x76f13af4 in pa_asyncmsgq_flush (a=0x42ed8, run=run@entry=true)
at pulsecore/
#4 0x76f77720 in pa_thread_mq_done (q=q@entry=0x4024c)
at pulsecore/
#5 0x7169c710 in stop_thread (u=u@entry=0x40210)
at modules/
#6 0x7169d2cc in set_profile_cb (c=<optimized out>, new_profile=
at modules/
#7 0x76f259e0 in pa_card_set_profile (c=c@entry=0x49e00, profile=0x56f60,
save=
#8 0x71699b9c in transport_
u=0x40210) at modules/
#9 0x76f2a92c in pa_hook_fire (hook=0x5ab98, data=data@
at pulsecore/
#10 0x716e4458 in transport_
state=
at modules/
#11 0x716e7de4 in endpoint_
conn=<optimized out>,
userdata=
#12 endpoint_handler (c=<optimized out>, m=0x5f1c0, userdata=0x5ab78)
at modules/
#13 0x76df1bd4 in ?? () from /lib/arm-
(you might need to `killall gst123` if it doesn't want to stop after pulse has crashed)
For me this is reproducible at 100% rate if the bluetooth device is just switched off and left off.
Incorporating this upstream patch makes this problem go away for me (~20 consecutive disconnects):
https:/
The original bug has a number of "defensive code reworkings" attached to the same upstream bug but I don't think they are necessary. I haven't tried to back-port them as they look riskier and more complicated.
pulseaudio version 5.0-13:
$ dpkg -l *pulse* | grep "^ii"
ii gstreamer1.
ii libpulse0:armhf 5.0-13 armhf PulseAudio client libraries
ii libpulsedsp:armhf 5.0-13 armhf PulseAudio OSS pre-load library
ii pulseaudio 5.0-13 armhf PulseAudio sound server
ii pulseaudio-
ii pulseaudio-
ii pulseaudio-utils 5.0-13 armhf Command line tools for the PulseAudio sound server