Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

pulseaudio deadlocks on musl #15631

Closed
jnbr opened this issue Oct 19, 2019 · 1 comment
Closed

pulseaudio deadlocks on musl #15631

jnbr opened this issue Oct 19, 2019 · 1 comment
Labels
bug Something isn't working

Comments

@jnbr
Copy link
Contributor

jnbr commented Oct 19, 2019

On musl systems, pulseaudio's pa_threaded_mainloop deadlocks.
This is used by gstreamer's pulseaudio sink and thus affects many packages.

Example code to trigger the bug: https://gist.github.com/jnbr/e622b3cf5020afdf28b68dd3195ded16

And backtrace:

Thread 4 (LWP 26160):
#0  0x00007ffff7f8c15a in __syscall6 (a6=<optimized out>, a5=<optimized out>, a4=<optimized out>, a3=<optimized out>, a2=<optimized out>, a1=<optimized out>, n=202) at ./arch/x86_64/syscall_arch.h:59
#1  syscall (n=n@entry=202) at src/misc/syscall.c:20
#2  0x00007ffff7ca4e98 in g_cond_wait_until (end_time=<optimized out>, mutex=0x555555568e60, cond=0x555555568e68) at ../glib/gthread-posix.c:1470
#3  g_cond_wait_until (cond=0x555555568e68, mutex=0x555555568e60, end_time=<optimized out>) at ../glib/gthread-posix.c:1443
#4  0x00007ffff7d21561 in g_async_queue_pop_intern_unlocked (queue=queue@entry=0x555555568e60, wait=wait@entry=1, end_time=end_time@entry=273715104932) at ../glib/gasyncqueue.c:422
#5  0x00007ffff7d21732 in g_async_queue_timeout_pop (queue=0x555555568e60, timeout=<optimized out>) at ../glib/gasyncqueue.c:545
#6  0x00007ffff7cc89c9 in g_thread_pool_wait_for_new_pool () at ../glib/gthreadpool.c:168
#7  g_thread_pool_thread_proxy (data=<optimized out>) at ../glib/gthreadpool.c:365
#8  0x00007ffff7ccc14d in g_thread_proxy (data=0x5555557914a0) at ../glib/gthread.c:805
#9  0x00007ffff7fb5a21 in start (p=<optimized out>) at src/thread/pthread_create.c:195
#10 0x00007ffff7fc319b in __clone () at src/thread/x86_64/clone.s:22
Backtrace stopped: frame did not save the PC

Thread 3 (LWP 26159):
#0  0x00007ffff7f8c15a in __syscall6 (a6=<optimized out>, a5=<optimized out>, a4=<optimized out>, a3=<optimized out>, a2=<optimized out>, a1=<optimized out>, n=202) at ./arch/x86_64/syscall_arch.h:59
#1  syscall (n=n@entry=202) at src/misc/syscall.c:20
#2  0x00007ffff7ca42df in g_cond_wait (cond=cond@entry=0x555555772650, mutex=mutex@entry=0x555555772648) at ../glib/gthread-posix.c:1422
#3  0x00007ffff7436b8b in gst_base_sink_wait_preroll (sink=sink@entry=0x555555772520 [GstBaseSink|sink]) at ../libs/gst/base/gstbasesink.c:2370
#4  0x00007ffff74b959b in gst_audio_base_sink_render (bsink=0x555555772520 [GstBaseSink|sink], buf=0x55555578c7e0 [None]) at ../gst-libs/gst/audio/gstaudiobasesink.c:2151
#5  0x00007ffff7431e2a in gst_base_sink_chain_unlocked.isra.0.lto_priv.0 (basesink=0x555555772520 [GstBaseSink|sink], obj=0x55555578c7e0, is_list=0, pad=<optimized out>) at ../libs/gst/base/gstbasesink.c:3649
#6  0x00007ffff74349d0 in gst_base_sink_chain_main (basesink=0x555555772520 [GstBaseSink|sink], pad=<optimized out>, obj=0x55555578c7e0, is_list=0) at ../libs/gst/base/gstbasesink.c:3775
#7  0x00007ffff7e8a47f in gst_pad_chain_data_unchecked (pad=pad@entry=0x555555768390 [GstPad|sink], type=type@entry=4112, data=data@entry=0x55555578c7e0) at ../gst/gstpad.c:4327
#8  0x00007ffff7e8af01 in gst_pad_push_data (pad=pad@entry=0x555555768140 [GstPad|src], type=type@entry=4112, data=data@entry=0x55555578c7e0) at ../gst/gstpad.c:4583
#9  0x00007ffff7e8b476 in gst_pad_push (pad=pad@entry=0x555555768140 [GstPad|src], buffer=0x55555578c7e0 [None]) at ../gst/gstpad.c:4702
#10 0x00007ffff742e285 in gst_base_src_loop (pad=0x555555768140 [GstPad|src]) at ../libs/gst/base/gstbasesrc.c:2974
#11 0x00007ffff7e546df in gst_task_func (task=0x55555578c050 [GstTask|source:src]) at ../gst/gsttask.c:328
#12 0x00007ffff7cc8924 in g_thread_pool_thread_proxy (data=<optimized out>) at ../glib/gthreadpool.c:308
#13 0x00007ffff7ccc14d in g_thread_proxy (data=0x5555555b4de0) at ../glib/gthread.c:805
#14 0x00007ffff7fb5a21 in start (p=<optimized out>) at src/thread/pthread_create.c:195
#15 0x00007ffff7fc319b in __clone () at src/thread/x86_64/clone.s:22
Backtrace stopped: frame did not save the PC

Thread 2 (LWP 26158):
#0  __syscall_cp_c (nr=202, u=140737331214116, v=128, w=0, x=0, y=0, z=0) at ./arch/x86_64/syscall_arch.h:61
#1  0x00007ffff7fb3ce7 in __timedwait_cp (addr=addr@entry=0x7ffff6a23724, val=val@entry=0, clk=clk@entry=0, at=at@entry=0x0, priv=128, priv@entry=1) at src/thread/__timedwait.c:31
#2  0x00007ffff7fb3dee in __timedwait (addr=addr@entry=0x7ffff6a23724, val=val@entry=0, clk=clk@entry=0, at=at@entry=0x0, priv=priv@entry=1) at src/thread/__timedwait.c:48
#3  0x00007ffff7fb6a4d in pthread_mutex_timedlock_pi (at=0x0, m=<optimized out>) at src/thread/pthread_mutex_timedlock.c:33
#4  __pthread_mutex_timedlock (m=<optimized out>, at=at@entry=0x0) at src/thread/pthread_mutex_timedlock.c:50
#5  0x00007ffff7fb680c in __pthread_mutex_lock (m=m@entry=0x555555772f40) at src/thread/pthread_mutex_lock.c:9
#6  0x00007ffff72a39fe in pa_mutex_lock (m=m@entry=0x555555772f40) at pulsecore/mutex-posix.c:90
#7  0x00007ffff730749d in poll_func (ufds=<optimized out>, nfds=3, timeout=10, userdata=0x555555772f40) at pulse/thread-mainloop.c:71
#8  0x00007ffff72f8db9 in pa_mainloop_poll (m=m@entry=0x5555557748a0) at pulse/mainloop.c:824
#9  0x00007ffff72f943f in pa_mainloop_iterate (m=0x5555557748a0, block=<optimized out>, retval=0x0) at pulse/mainloop.c:926
#10 0x00007ffff72f94f0 in pa_mainloop_run (m=0x5555557748a0, retval=retval@entry=0x0) at pulse/mainloop.c:945
#11 0x00007ffff73073d9 in thread (userdata=0x555555772ee0) at pulse/thread-mainloop.c:101
#12 0x00007ffff72a4888 in internal_thread_func (userdata=0x5555557749c0) at pulsecore/thread-posix.c:81
#13 0x00007ffff7fb5a21 in start (p=<optimized out>) at src/thread/pthread_create.c:195
#14 0x00007ffff7fc319b in __clone () at src/thread/x86_64/clone.s:22
Backtrace stopped: frame did not save the PC

Thread 1 (LWP 26154):
#0  __cp_end () at src/thread/x86_64/syscall_cp.s:29
#1  0x00007ffff7fb4a36 in __syscall_cp_c (nr=202, u=140737488347268, v=128, w=<optimized out>, x=<optimized out>, y=<optimized out>, z=0) at src/thread/pthread_cancel.c:33
#2  0x00007ffff7fb3ce7 in __timedwait_cp (addr=addr@entry=0x7fffffffe084, val=val@entry=2, clk=clk@entry=0, at=at@entry=0x0, priv=128, priv@entry=1) at src/thread/__timedwait.c:31
#3  0x00007ffff7fb4e91 in __pthread_cond_timedwait (c=0x555555772f80, m=0x555555772f40, ts=ts@entry=0x0) at src/thread/pthread_cond_timedwait.c:100
#4  0x00007ffff7fb55c7 in pthread_cond_wait (c=<optimized out>, m=<optimized out>) at src/thread/pthread_cond_wait.c:5
#5  0x00007ffff72a3e17 in pa_cond_wait (c=<optimized out>, m=<optimized out>) at pulsecore/mutex-posix.c:139
--Type <RET> for more, q to quit, c to continue without paging--
#6  0x00007ffff7307b28 in pa_threaded_mainloop_wait (m=0x555555772ee0) at pulse/thread-mainloop.c:216
#7  0x00007ffff733bd28 in gst_pulsering_set_corked (pbuf=pbuf@entry=0x55555577a070 [GstPulseRingBuffer|pulseringbuffer0], corked=corked@entry=1, wait=wait@entry=1) at ../ext/pulse/pulsesink.c:1137
#8  0x00007ffff733d54b in gst_pulseringbuffer_pause (buf=0x55555577a070 [GstAudioRingBuffer|pulseringbuffer0]) at ../ext/pulse/pulsesink.c:1268
#9  0x00007ffff7491039 in gst_audio_ring_buffer_pause_unlocked (buf=buf@entry=0x55555577a070 [GstAudioRingBuffer|pulseringbuffer0]) at ../gst-libs/gst/audio/gstaudioringbuffer.c:1060
#10 0x00007ffff74947a0 in gst_audio_ring_buffer_pause (buf=0x55555577a070 [GstAudioRingBuffer|pulseringbuffer0]) at ../gst-libs/gst/audio/gstaudioringbuffer.c:1103
#11 0x00007ffff74b62fe in gst_audio_base_sink_change_state (element=0x555555772520 [GstElement|sink], transition=<optimized out>) at ../gst-libs/gst/audio/gstaudiobasesink.c:2454
#12 0x00007ffff7338ee3 in gst_pulsesink_change_state (element=0x555555772520 [GstElement|sink], transition=GST_STATE_CHANGE_PLAYING_TO_PAUSED) at ../ext/pulse/pulsesink.c:3265
#13 0x00007ffff7eaa745 in gst_element_change_state (element=element@entry=0x555555772520 [GstElement|sink], transition=transition@entry=GST_STATE_CHANGE_PLAYING_TO_PAUSED) at ../gst/gstelement.c:2952
#14 0x00007ffff7eaae59 in gst_element_set_state_func (element=0x555555772520 [GstElement|sink], state=GST_STATE_PAUSED) at ../gst/gstelement.c:2906
#15 0x00007ffff7ece0e8 in gst_bin_element_set_state (next=GST_STATE_PAUSED, current=GST_STATE_PLAYING, start_time=1990685000 [0:00:01.990685000], base_time=0 [0:00:00.000000000], element=0x555555772520 [GstElement|sink], bin=0x5555557761c0 [GstBin|test-pipeline]) at ../gst/gstbin.c:2605
#16 gst_bin_change_state_func (element=0x5555557761c0 [GstElement|test-pipeline], transition=GST_STATE_CHANGE_PLAYING_TO_PAUSED) at ../gst/gstbin.c:2947
#17 0x00007ffff7e816a7 in gst_pipeline_change_state (element=0x5555557761c0 [GstElement|test-pipeline], transition=GST_STATE_CHANGE_PLAYING_TO_PAUSED) at ../gst/gstpipeline.c:504
#18 0x00007ffff7eaa745 in gst_element_change_state (element=element@entry=0x5555557761c0 [GstElement|test-pipeline], transition=transition@entry=GST_STATE_CHANGE_PLAYING_TO_PAUSED) at ../gst/gstelement.c:2952
#19 0x00007ffff7eaae59 in gst_element_set_state_func (element=0x5555557761c0 [GstElement|test-pipeline], state=GST_STATE_PAUSED) at ../gst/gstelement.c:2906
#20 0x00005555555554f1 in main (argc=1, argv=0x7fffffffe508) at test.c:47
@jnbr jnbr added the bug Something isn't working label Oct 19, 2019
@ncopa
Copy link

ncopa commented Aug 10, 2020

@q66 q66 closed this as completed in 53d00ff Aug 2, 2021
atweiden added a commit to atweiden/voidpkgs that referenced this issue Aug 19, 2021
…/github.com/pulseaudio/pulseaudio/blob/master/src/pulsecore/mutex-posix.c#L55 https://github.com/pulseaudio/pulseaudio/blob/master/src/pulse/thread-mainloop.c#L118

pulseaudio/pulseaudio@413a8f8

pulseaudio uses a prio-inheriting mutex since the above revision
that is paised with a condition variable; the behavior of this
was broken in musl until the above patches, which would result
in pulseaudio deadlocking with gstreamer pulsesink (most often
with webkit) and possibly other things.

Fixes void-linux/void-packages#15631

void-linux/void-packages@53d00ff
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants