TokTok/toxic

deadlock on sound_notify

dokthar opened this issue · 1 comments

Running Linux 5.11.4-1-ARCH SMP aarch64 GNU/Linux on a Raspberry pi 3

Toxic version 0.10.1_r1980
Toxcore version 0.2.12

to make things more simple, I've build toxic with the following options:
make DISABLE_X11=1 DISABLE_AV=0 DISABLE_SOUND_NOTIFY=0 DISABLE_QRCODE=1 DISABLE_QRPNG=1 clean all
I don't have this issue when setting DISABLE_AV=1 DISABLE_SOUND_NOTIFY=1

edit: running headless on a raspberry, no X and without speakers (I hope so)


  Id   Target Id                                Frame
* 1    Thread 0xfffff65c5810 (LWP 8645) "toxic" 0x0000fffff7b82490 in __lll_lock_wait () from /usr/lib/libpthread.so.0
  2    Thread 0xfffff5cbbeb0 (LWP 8648) "toxic" 0x0000fffff7a9c600 in clock_nanosleep@@GLIBC_2.17 () from /usr/lib/libc.so.6
  3    Thread 0xffffed4baeb0 (LWP 8649) "toxic" 0x0000fffff7b82490 in __lll_lock_wait () from /usr/lib/libpthread.so.0
  4    Thread 0xfffff54baeb0 (LWP 8650) "toxic" 0x0000fffff7b82490 in __lll_lock_wait () from /usr/lib/libpthread.so.0
  5    Thread 0xfffff4cb9eb0 (LWP 8651) "toxic" 0x0000fffff7b82490 in __lll_lock_wait () from /usr/lib/libpthread.so.0
  6    Thread 0xffffefffeeb0 (LWP 8652) "toxic" 0x0000fffff7b82490 in __lll_lock_wait () from /usr/lib/libpthread.so.0

thread 1 (LWP 8645)

(gdb) bt
#0  0x0000fffff7b82490 in __lll_lock_wait () at /usr/lib/libpthread.so.0
#1  0x0000fffff7b7a0b8 in pthread_mutex_lock () at /usr/lib/libpthread.so.0
#2  0x0000aaaaaaad95c8 in do_toxic (m=0xaaaaaab8b420) at /home/dok/depots/toxic/src/toxic.c:1058
#3  0x0000aaaaaaadad08 in main (argc=1, argv=0xfffffffff5b8) at /home/dok/depots/toxic/src/toxic.c:1608

waiting for

#2  0x0000aaaaaaad95c8 in do_toxic (m=0xaaaaaab8b420) at /home/dok/depots/toxic/src/toxic.c:1058
1058        pthread_mutex_lock(&Winthread.lock);
(gdb) p Winthread.lock
$3 = {__data = {__lock = 2, __count = 0, __owner = 8650, __nusers = 1, __kind = 0, __spins = 0, __list = {__prev = 0x0, __next = 0x0}},
  __size = "\002\000\000\000\000\000\000\000\312!\000\000\001", '\000' <repeats 34 times>, __align = 2}

thread 3 (LWP 8649)

Waiting for the same lock as thread 1

(gdb) bt
#0  0x0000fffff7b82490 in __lll_lock_wait () at /usr/lib/libpthread.so.0
#1  0x0000fffff7b7a0b8 in pthread_mutex_lock () at /usr/lib/libpthread.so.0
#2  0x0000aaaaaaad97d0 in thread_av (data=0xaaaaaad1a670) at /home/dok/depots/toxic/src/toxic.c:1127
#3  0x0000fffff7b77f44 in start_thread () at /usr/lib/libpthread.so.0
#4  0x0000fffff7acf95c in thread_start () at /usr/lib/libc.so.6
(gdb) frame 2
#2  0x0000aaaaaaad97d0 in thread_av (data=0xaaaaaad1a670) at /home/dok/depots/toxic/src/toxic.c:1127
1127            pthread_mutex_lock(&Winthread.lock);
(gdb) p Winthread.lock
$4 = {__data = {__lock = 2, __count = 0, __owner = 8650, __nusers = 1, __kind = 0, __spins = 0, __list = {__prev = 0x0, __next = 0x0}},
  __size = "\002\000\000\000\000\000\000\000\312!\000\000\001", '\000' <repeats 34 times>, __align = 2}

thread 4 (LWP 8650)

(gdb) bt
#0  0x0000fffff7b82490 in __lll_lock_wait () at /usr/lib/libpthread.so.0
#1  0x0000fffff7b7a0b8 in pthread_mutex_lock () at /usr/lib/libpthread.so.0
#2  0x0000aaaaaaae13f0 in lock (type=output) at /home/dok/depots/toxic/src/audio_device.c:105
#3  0x0000aaaaaaae2850 in open_device
    (type=output, device_idx=0xaaaaaab07d4c <Control+68>, cb=0x0, cb_data=0x0, enable_VAD=false, sample_rate=48000, frame_duration=20, channels=1 '\001')
    at /home/dok/depots/toxic/src/audio_device.c:508
#4  0x0000aaaaaaae2b3c in open_output_device (device_idx=0xaaaaaab07d4c <Control+68>, sample_rate=48000, frame_duration=20, channels=1 '\001')
    at /home/dok/depots/toxic/src/audio_device.c:562
#5  0x0000aaaaaaace01c in m_open_device () at /home/dok/depots/toxic/src/notify.c:185
#6  0x0000aaaaaaacef00 in play_sound_internal (what=notif_error, loop=false) at /home/dok/depots/toxic/src/notify.c:513
#7  0x0000aaaaaaacf0a8 in play_notify_sound (notif=notif_error, flags=0) at /home/dok/depots/toxic/src/notify.c:546
#8  0x0000aaaaaaacf2e8 in m_play_sound (notif=notif_error, flags=0) at /home/dok/depots/toxic/src/notify.c:576
#9  0x0000aaaaaaacf3b4 in sound_notify (self=0xffffe8025f70, notif=notif_error, flags=0, id_indicator=0x0) at /home/dok/depots/toxic/src/notify.c:599
#10 0x0000aaaaaaac4e58 in input_backspace (self=0xffffe8025f70, x=0, mx_x=170) at /home/dok/depots/toxic/src/input.c:74
#11 0x0000aaaaaaac5c74 in input_handle (self=0xffffe8025f70, key=127, x=0, mx_x=170) at /home/dok/depots/toxic/src/input.c:270
#12 0x0000aaaaaaaaede4 in chat_onKey (self=0xffffe8025f70, m=0xaaaaaab8b420, key=127, ltr=false) at /home/dok/depots/toxic/src/chat.c:1093
#13 0x0000aaaaaaade468 in draw_active_window (m=0xaaaaaab8b420) at /home/dok/depots/toxic/src/windows.c:725
#14 0x0000aaaaaaad966c in thread_winref (data=0xaaaaaab8b420) at /home/dok/depots/toxic/src/toxic.c:1081
#15 0x0000fffff7b77f44 in start_thread () at /usr/lib/libpthread.so.0
#16 0x0000fffff7acf95c in thread_start () at /usr/lib/libc.so.6

waiting for lock:

#2  0x0000aaaaaaae13f0 in lock (type=output) at /home/dok/depots/toxic/src/audio_device.c:105
105         pthread_mutex_lock(&audio_state->mutex[type]);
(gdb) p audio_state->mutex[type]
$6 = {__data = {__lock = 2, __count = 0, __owner = 8652, __nusers = 1, __kind = 0, __spins = 0, __list = {__prev = 0x0, __next = 0x0}},
  __size = "\002\000\000\000\000\000\000\000\314!\000\000\001", '\000' <repeats 34 times>, __align = 2}

Accuired by thread 6 (8652)

thread 6 (LWP 8652)

(gdb) bt
#0  0x0000fffff7b82490 in __lll_lock_wait () at /usr/lib/libpthread.so.0
#1  0x0000fffff7b7a0b8 in pthread_mutex_lock () at /usr/lib/libpthread.so.0
#2  0x0000aaaaaaacdec8 in control_lock () at /home/dok/depots/toxic/src/notify.c:150
#3  0x0000aaaaaaace360 in do_playing (_p=0x0) at /home/dok/depots/toxic/src/notify.c:254
#4  0x0000fffff7b77f44 in start_thread () at /usr/lib/libpthread.so.0
#5  0x0000fffff7acf95c in thread_start () at /usr/lib/libc.so.6

Waiting on a lock accuired by thread 4:

#2  0x0000aaaaaaacdec8 in control_lock () at /home/dok/depots/toxic/src/notify.c:150
150         pthread_mutex_lock(Control.poll_mutex);
(gdb) p Control.poll_mutex
$7 = {{__data = {__lock = 2, __count = 0, __owner = 8650, __nusers = 1, __kind = 0, __spins = 0, __list = {__prev = 0x0, __next = 0x0}},
    __size = "\002\000\000\000\000\000\000\000\312!\000\000\001", '\000' <repeats 34 times>, __align = 2}}

thread 5

(gdb) t 5
[Switching to thread 5 (Thread 0xfffff4cb9eb0 (LWP 8651))]
#0  0x0000fffff7b82490 in __lll_lock_wait () from /usr/lib/libpthread.so.0
(gdb) bt
#0  0x0000fffff7b82490 in __lll_lock_wait () at /usr/lib/libpthread.so.0
#1  0x0000fffff7b7a0b8 in pthread_mutex_lock () at /usr/lib/libpthread.so.0
#2  0x0000aaaaaaad9714 in thread_cqueue (data=0xaaaaaab8b420) at /home/dok/depots/toxic/src/toxic.c:1104
#3  0x0000fffff7b77f44 in start_thread () at /usr/lib/libpthread.so.0
#4  0x0000fffff7acf95c in thread_start () at /usr/lib/libc.so.6
(gdb) frame 2
#2  0x0000aaaaaaad9714 in thread_cqueue (data=0xaaaaaab8b420) at /home/dok/depots/toxic/src/toxic.c:1104
1104            pthread_mutex_lock(&Winthread.lock);
(gdb) p Winthread.lock
$8 = {__data = {__lock = 2, __count = 0, __owner = 8650, __nusers = 1, __kind = 0, __spins = 0, __list = {__prev = 0x0, __next = 0x0}},
  __size = "\002\000\000\000\000\000\000\000\312!\000\000\001", '\000' <repeats 34 times>, __align = 2}

Appears to be fixed by #185