Fedora 28 pjsua: seeing deadlocks with alsa->pulse virtual sound card

AA
Anthony Alba
Mon, Apr 23, 2018 1:08 AM

Hi pjsip listers,

On master branch I am seeing an alsa->pulse deadlock on Fedora 28 using
the pjsua CLI. It looks like it has something to do with closing the
soundcard gracefully.

If I blacklist the soundcard from pulse, and use pure
alsa-><hardware>, it works.

Otherwise, after making call there is a deadlock when
the call ends or when trying to exit pjsua gracefully.

The same setup worked under Fedora 28.
Notes:

  1. Fedora 28 is using ffmpeg 3.5; to compile I need the flag

CFLAGS+=-DFF_INPUT_BUFFER_PADDING_SIZE=AV_INPUT_BUFFER_PADDING_SIZE

  1. pjmedia is compiled with alsa; and alsa is configure to use pulse
    as default soundcard

#0  0x00007fd7b7dca7ed in __lll_lock_wait ()
at ../sysdeps/unix/sysv/linux/x86_64/lowlevellock.S:135
#1  0x00007fd7b7dc3d64 in __GI___pthread_mutex_lock
(mutex=mutex@entry=0x23f7d78) at ../nptl/pthread_mutex_lock.c:113
#2  0x00007fd7b90dc996 in pj_mutex_lock (mutex=0x23f7d78)
at ../src/pj/os_core_unix.c:1281
#3  0x00007fd7bb965866 in PJSUA_LOCK ()
at ../include/pjsua-lib/pjsua_internal.h:582
#4  0x00007fd7bb965866 in pjsua_enum_accs
(ids=ids@entry=0x7fffcf228520, count=count@entry=0x7fffcf22851c) at
../src/pjsua-lib/pjsua_acc.c:2863

(gdb) up 2
#2  0x00007fd7b90dc996 in pj_mutex_lock (mutex=0x23f7d78)
at ../src/pj/os_core_unix.c:1281
1281        status = pthread_mutex_lock( &mutex->mutex );

(gdb) print ((&mutex->mutex).__data.__owner)
$1 = 2569

(gdb) thread find 2569
Thread 13 has target id 'Thread 0x7fd788e87700 (LWP 2569)'

#0  0x00007fd7b7dc29fd in __GI___pthread_timedjoin_ex (
threadid=140563122738944,
thread_return=thread_return@entry=0x7fd788e86528,
abstime=abstime@entry=0x0, block=block@entry=true)
at pthread_join_common.c:89
89        lll_wait_tid (pd->tid);

(gdb) bt
#0  0x00007fd7b7dc29fd in __GI___pthread_timedjoin_ex
(threadid=140563122738944,
thread_return=thread_return@entry=0x7fd788e86528,
abstime=abstime@entry=0x0, block=block@entry=true) at
pthread_join_common.c:89
#1  0x00007fd7b7dc282c in __pthread_join (threadid=<optimized out>,
thread_return=thread_return@entry=0x7fd788e86528) at pthread_join.c:24
#2  0x00007fd7b90dc805 in pj_thread_join (p=0x249fe20)
at ../src/pj/os_core_unix.c:724
#3  0x00007fd7baa3950a in alsa_stream_stop (s=0x24a20f8)
at ../src/pjmedia-audiodev/alsa_dev.c:1042
#4  0x00007fd7bae90b92 in pjmedia_aud_stream_stop (strm=<optimized out>)
at ../src/pjmedia/audiodev.c:619
#5  0x00007fd7bae75042 in stop_sound_device (snd_port=0x2497068)
at ../src/pjmedia/sound_port.c:347
#6  0x00007fd7bae750c1 in pjmedia_snd_port_destroy
(snd_port=<optimized out>) at ../src/pjmedia/sound_port.c:538
#7  0x00007fd7bb988f26 in close_snd_dev ()
at ../src/pjsua-lib/pjsua_aud.c:1943
#8  0x00007fd7bb98920d in close_snd_timer_cb (th=<optimized out>,
entry=0x7fd7bbc1ca90 <pjsua_var+512272>) at
../src/pjsua-lib/pjsua_aud.c:447
#9  0x00007fd7b90ed5d4 in pj_timer_heap_poll (ht=0x23f84b0,
next_delay=next_delay@entry=0x7fd788e869b0) at ../src/pj/timer.c:646
#10 0x00007fd7bb2f121c in pjsip_endpt_handle_events2 (endpt=0x23f8188,
max_timeout=max_timeout@entry=0x7fd788e869f0,
p_count=p_count@entry=0x7fd788e86a0c) at
../src/pjsip/sip_endpoint.c:715
#11 0x00007fd7bb9766d3 in pjsua_handle_events
(msec_timeout=msec_timeout@entry=10) at
../src/pjsua-lib/pjsua_core.c:2068

Any ideas to help troubleshoot further?

Thanks
Anthony

Hi pjsip listers, On master branch I am seeing an alsa->pulse deadlock on Fedora 28 using the pjsua CLI. It looks like it has something to do with closing the soundcard gracefully. If I blacklist the soundcard from pulse, and use pure alsa-><hardware>, it works. Otherwise, after making call there is a deadlock when the call ends or when trying to exit pjsua gracefully. The same setup worked under Fedora 28. Notes: 1. Fedora 28 is using ffmpeg 3.5; to compile I need the flag CFLAGS+=-DFF_INPUT_BUFFER_PADDING_SIZE=AV_INPUT_BUFFER_PADDING_SIZE 2. pjmedia is compiled with alsa; and alsa is configure to use pulse as default soundcard #0 0x00007fd7b7dca7ed in __lll_lock_wait () at ../sysdeps/unix/sysv/linux/x86_64/lowlevellock.S:135 #1 0x00007fd7b7dc3d64 in __GI___pthread_mutex_lock (mutex=mutex@entry=0x23f7d78) at ../nptl/pthread_mutex_lock.c:113 #2 0x00007fd7b90dc996 in pj_mutex_lock (mutex=0x23f7d78) at ../src/pj/os_core_unix.c:1281 #3 0x00007fd7bb965866 in PJSUA_LOCK () at ../include/pjsua-lib/pjsua_internal.h:582 #4 0x00007fd7bb965866 in pjsua_enum_accs (ids=ids@entry=0x7fffcf228520, count=count@entry=0x7fffcf22851c) at ../src/pjsua-lib/pjsua_acc.c:2863 (gdb) up 2 #2 0x00007fd7b90dc996 in pj_mutex_lock (mutex=0x23f7d78) at ../src/pj/os_core_unix.c:1281 1281 status = pthread_mutex_lock( &mutex->mutex ); (gdb) print ((&mutex->mutex).__data.__owner) $1 = 2569 (gdb) thread find 2569 Thread 13 has target id 'Thread 0x7fd788e87700 (LWP 2569)' #0 0x00007fd7b7dc29fd in __GI___pthread_timedjoin_ex ( threadid=140563122738944, thread_return=thread_return@entry=0x7fd788e86528, abstime=abstime@entry=0x0, block=block@entry=true) at pthread_join_common.c:89 89 lll_wait_tid (pd->tid); (gdb) bt #0 0x00007fd7b7dc29fd in __GI___pthread_timedjoin_ex (threadid=140563122738944, thread_return=thread_return@entry=0x7fd788e86528, abstime=abstime@entry=0x0, block=block@entry=true) at pthread_join_common.c:89 #1 0x00007fd7b7dc282c in __pthread_join (threadid=<optimized out>, thread_return=thread_return@entry=0x7fd788e86528) at pthread_join.c:24 #2 0x00007fd7b90dc805 in pj_thread_join (p=0x249fe20) at ../src/pj/os_core_unix.c:724 #3 0x00007fd7baa3950a in alsa_stream_stop (s=0x24a20f8) at ../src/pjmedia-audiodev/alsa_dev.c:1042 #4 0x00007fd7bae90b92 in pjmedia_aud_stream_stop (strm=<optimized out>) at ../src/pjmedia/audiodev.c:619 #5 0x00007fd7bae75042 in stop_sound_device (snd_port=0x2497068) at ../src/pjmedia/sound_port.c:347 #6 0x00007fd7bae750c1 in pjmedia_snd_port_destroy (snd_port=<optimized out>) at ../src/pjmedia/sound_port.c:538 #7 0x00007fd7bb988f26 in close_snd_dev () at ../src/pjsua-lib/pjsua_aud.c:1943 #8 0x00007fd7bb98920d in close_snd_timer_cb (th=<optimized out>, entry=0x7fd7bbc1ca90 <pjsua_var+512272>) at ../src/pjsua-lib/pjsua_aud.c:447 #9 0x00007fd7b90ed5d4 in pj_timer_heap_poll (ht=0x23f84b0, next_delay=next_delay@entry=0x7fd788e869b0) at ../src/pj/timer.c:646 #10 0x00007fd7bb2f121c in pjsip_endpt_handle_events2 (endpt=0x23f8188, max_timeout=max_timeout@entry=0x7fd788e869f0, p_count=p_count@entry=0x7fd788e86a0c) at ../src/pjsip/sip_endpoint.c:715 #11 0x00007fd7bb9766d3 in pjsua_handle_events (msec_timeout=msec_timeout@entry=10) at ../src/pjsua-lib/pjsua_core.c:2068 Any ideas to help troubleshoot further? Thanks Anthony
AA
Anthony Alba
Mon, Apr 23, 2018 2:19 AM

Sorry - typo - that should have been:
The same setup worked under Fedora 27

The same setup worked under Fedora 28.

Thanks
Anthony

Sorry - typo - that should have been: The same setup worked under Fedora 27 > > The same setup worked under Fedora 28. > Thanks Anthony