Input deadlocked when changing program in TS record
I have a DVB recording generated with the VLC record button. The "first" program (ID 100) is encrypted and thus unwatchable. When selecting the second program (ID 200) from the menu, the input thread gets into a deadlock after "caching".
Even stop will not recover the input. VLC has to be killed. This is reliably reproducible with all VLC versions 1.1.13, 2.0.1 and 2.1-git. Be sure to select the program BEFORE EOF otherwise the bug will not hit. As far as I can tell, the stack trace does not show any lock inversion; simply put, all threads are waiting for another one to do something, and nothing ever happens:
[0x838b2a8] main input debug: control type=5
[0x838b2a8] main input debug: unselecting program id=100
[0x838b2a8] main input debug: selecting program id=200
[0x85295f0] main decoder debug: looking for decoder module: 30 candidates
[0x85295f0] avcodec decoder debug: trying to use direct rendering
[0x85295f0] avcodec decoder debug: allowing 3 thread(s) for decoding
[New Thread 0xaf7e5b70 (LWP 6224)]
[New Thread 0xaefe5b70 (LWP 6225)]
[New Thread 0xae7e5b70 (LWP 6226)]
[0x85295f0] avcodec decoder debug: ffmpeg codec (MPEG-1/2 Video) started
[0x85295f0] avcodec decoder debug: using slice thread mode with 3 threads
[0x85295f0] main decoder debug: using decoder module "avcodec"
[0x8477678] main packetizer debug: looking for packetizer module: 21 candidates
[0x8477678] main packetizer debug: using packetizer module "packetizer_mpegvideo"
[New Thread 0xadfe5b70 (LWP 6227)]
[0x847c5d8] main decoder debug: looking for decoder module: 30 candidates
[0x847c5d8] main decoder debug: using decoder module "mpeg_audio"
[New Thread 0xadf65b70 (LWP 6228)]
[0x839a810] ts demux debug: DEMUX_SET_GROUP 200 (nil)
[0x838b2a8] main input debug: Stream buffering done (131351 ms in 3885 ms)
[0x838b2a8] main input debug: Decoder buffering done in 0 ms
^Z
Program received signal SIGTSTP, Stopped (user).
0xb7f9ecc8 in do_sigwait (set=0xbffff0f4, sig=<optimized out>)
at ../nptl/sysdeps/unix/sysv/linux/../../../../../sysdeps/unix/sysv/linux/sigwait.c:63
63 ../nptl/sysdeps/unix/sysv/linux/../../../../../sysdeps/unix/sysv/linux/sigwait.c: Aucun fichier ou dossier de ce type.
(gdb) thread apply all bt
Thread 11 (Thread 0xadf65b70 (LWP 6228)):
[#0](https://code.videolan.org/videolan/vlc/-/issues/0) 0xb7f9aea5 in __pthread_cond_wait (cond=0x847c8e0, mutex=0x847c8c8)
at pthread_cond_wait.c:153
[#1](https://code.videolan.org/videolan/vlc/-/issues/1) 0xb7df8ba3 in vlc_cond_wait (p_condvar=p_condvar@entry=0x847c8e0,
p_mutex=p_mutex@entry=0x847c8c8) at ../../src/posix/thread.c:431
[#2](https://code.videolan.org/videolan/vlc/-/issues/2) 0xb7dd8eb9 in block_FifoGet (p_fifo=0x847c8c8)
at ../../src/misc/block.c:620
[#3](https://code.videolan.org/videolan/vlc/-/issues/3) 0xb7d8dcde in DecoderThread (p_data=0x847c5d8)
at ../../src/input/decoder.c:918
[#4](https://code.videolan.org/videolan/vlc/-/issues/4) 0xb7f96954 in start_thread (arg=0xadf65b70) at pthread_create.c:304
[#5](https://code.videolan.org/videolan/vlc/-/issues/5) 0xb7f1273e in clone () at ../sysdeps/unix/sysv/linux/i386/clone.S:130
Thread 10 (Thread 0xadfe5b70 (LWP 6227)):
[#0](https://code.videolan.org/videolan/vlc/-/issues/0) 0xb7f9aea5 in __pthread_cond_wait (cond=0x847f200, mutex=0x847f1e8)
at pthread_cond_wait.c:153
[#1](https://code.videolan.org/videolan/vlc/-/issues/1) 0xb7df8ba3 in vlc_cond_wait (p_condvar=p_condvar@entry=0x847f200,
p_mutex=p_mutex@entry=0x847f1e8) at ../../src/posix/thread.c:431
[#2](https://code.videolan.org/videolan/vlc/-/issues/2) 0xb7dd8eb9 in block_FifoGet (p_fifo=0x847f1e8)
at ../../src/misc/block.c:620
[#3](https://code.videolan.org/videolan/vlc/-/issues/3) 0xb7d8dcde in DecoderThread (p_data=0x85295f0)
at ../../src/input/decoder.c:918
[#4](https://code.videolan.org/videolan/vlc/-/issues/4) 0xb7f96954 in start_thread (arg=0xadfe5b70) at pthread_create.c:304
[#5](https://code.videolan.org/videolan/vlc/-/issues/5) 0xb7f1273e in clone () at ../sysdeps/unix/sysv/linux/i386/clone.S:130
Thread 9 (Thread 0xae7e5b70 (LWP 6226)):
[#0](https://code.videolan.org/videolan/vlc/-/issues/0) 0xb7f9aea5 in __pthread_cond_wait (cond=0x8477390, mutex=0x84773c0)
at pthread_cond_wait.c:153
[#1](https://code.videolan.org/videolan/vlc/-/issues/1) 0xb011eb1b in ?? () from /usr/lib/i386-linux-gnu/i686/cmov/libavcodec.so.53
[#2](https://code.videolan.org/videolan/vlc/-/issues/2) 0xb7f96954 in start_thread (arg=0xae7e5b70) at pthread_create.c:304
[#3](https://code.videolan.org/videolan/vlc/-/issues/3) 0xb7f1273e in clone () at ../sysdeps/unix/sysv/linux/i386/clone.S:130
Thread 8 (Thread 0xaefe5b70 (LWP 6225)):
[#0](https://code.videolan.org/videolan/vlc/-/issues/0) 0xb7f9aea5 in __pthread_cond_wait (cond=0x8477390, mutex=0x84773c0)
at pthread_cond_wait.c:153
[#1](https://code.videolan.org/videolan/vlc/-/issues/1) 0xb011eb1b in ?? () from /usr/lib/i386-linux-gnu/i686/cmov/libavcodec.so.53
[#2](https://code.videolan.org/videolan/vlc/-/issues/2) 0xb7f96954 in start_thread (arg=0xaefe5b70) at pthread_create.c:304
[#3](https://code.videolan.org/videolan/vlc/-/issues/3) 0xb7f1273e in clone () at ../sysdeps/unix/sysv/linux/i386/clone.S:130
Thread 7 (Thread 0xaf7e5b70 (LWP 6224)):
[#0](https://code.videolan.org/videolan/vlc/-/issues/0) 0xb7f9aea5 in __pthread_cond_wait (cond=0x8477390, mutex=0x84773c0)
at pthread_cond_wait.c:153
[#1](https://code.videolan.org/videolan/vlc/-/issues/1) 0xb011eb1b in ?? () from /usr/lib/i386-linux-gnu/i686/cmov/libavcodec.so.53
[#2](https://code.videolan.org/videolan/vlc/-/issues/2) 0xb7f96954 in start_thread (arg=0xaf7e5b70) at pthread_create.c:304
[#3](https://code.videolan.org/videolan/vlc/-/issues/3) 0xb7f1273e in clone () at ../sysdeps/unix/sysv/linux/i386/clone.S:130
Thread 6 (Thread 0xb78b9b70 (LWP 6223)):
[#0](https://code.videolan.org/videolan/vlc/-/issues/0) pthread_cond_timedwait@@GLIBC_2.3.2 ()
at ../nptl/sysdeps/unix/sysv/linux/i386/i486/pthread_cond_timedwait.S:237
[#1](https://code.videolan.org/videolan/vlc/-/issues/1) 0xb7df8c18 in vlc_cond_timedwait (p_condvar=p_condvar@entry=0x8392b5c,
p_mutex=p_mutex@entry=0x8392b44, deadline=21847143583)
at ../../src/posix/thread.c:454
[#2](https://code.videolan.org/videolan/vlc/-/issues/2) 0xb7da44c9 in ControlPop (b_postpone_seek=false, i_deadline=21847143583,
p_val=<synthetic pointer>, pi_type=<synthetic pointer>,
p_input=<optimized out>) at ../../src/input/input.c:1540
[#3](https://code.videolan.org/videolan/vlc/-/issues/3) MainLoop (p_input=p_input@entry=0x838b2a8,
b_interactive=b_interactive@entry=true) at ../../src/input/input.c:803
[#4](https://code.videolan.org/videolan/vlc/-/issues/4) 0xb7da535c in Run (obj=0x838b2a8) at ../../src/input/input.c:542
[#5](https://code.videolan.org/videolan/vlc/-/issues/5) 0xb7f96954 in start_thread (arg=0xb78b9b70) at pthread_create.c:304
[#6](https://code.videolan.org/videolan/vlc/-/issues/6) 0xb7f1273e in clone () at ../sysdeps/unix/sysv/linux/i386/clone.S:130
Thread 5 (Thread 0xb4f7bb70 (LWP 6222)):
[#0](https://code.videolan.org/videolan/vlc/-/issues/0) 0xb7f04edc in *__GI___poll (fds=0xb7f87ff4, nfds=4, timeout=24487)
at ../sysdeps/unix/sysv/linux/poll.c:87
[#1](https://code.videolan.org/videolan/vlc/-/issues/1) 0xb6e5207b in g_poll () from /lib/i386-linux-gnu/libglib-2.0.so.0
[#2](https://code.videolan.org/videolan/vlc/-/issues/2) 0xb6e43950 in ?? () from /lib/i386-linux-gnu/libglib-2.0.so.0
[#3](https://code.videolan.org/videolan/vlc/-/issues/3) 0xb6e43ab1 in g_main_context_iteration ()
from /lib/i386-linux-gnu/libglib-2.0.so.0
[#4](https://code.videolan.org/videolan/vlc/-/issues/4) 0xb70f7d31 in QEventDispatcherGlib::processEvents (this=0x804f530,
flags=...) at kernel/qeventdispatcher_glib.cpp:424
[#5](https://code.videolan.org/videolan/vlc/-/issues/5) 0xb53d432a in QGuiEventDispatcherGlib::processEvents (this=0x804f530,
flags=...) at kernel/qguieventdispatcher_glib.cpp:204
[#6](https://code.videolan.org/videolan/vlc/-/issues/6) 0xb70c487c in QEventLoop::processEvents (this=this@entry=0xb4f7b228,
flags=...) at kernel/qeventloop.cpp:149
[#7](https://code.videolan.org/videolan/vlc/-/issues/7) 0xb70c4b71 in QEventLoop::exec (this=0xb4f7b228, flags=...)
at kernel/qeventloop.cpp:204
[#8](https://code.videolan.org/videolan/vlc/-/issues/8) 0xb70c9fea in QCoreApplication::exec () at kernel/qcoreapplication.cpp:1148
[#9](https://code.videolan.org/videolan/vlc/-/issues/9) 0xb531f3b4 in QApplication::exec () at kernel/qapplication.cpp:3820
[#10](https://code.videolan.org/videolan/vlc/-/issues/10) 0xb73c79a6 in Thread (obj=0x80e1068)
at ../../../../modules/gui/qt4/qt4.cpp:535
[#11](https://code.videolan.org/videolan/vlc/-/issues/11) 0xb7f96954 in start_thread (arg=0xb4f7bb70) at pthread_create.c:304
[#12](https://code.videolan.org/videolan/vlc/-/issues/12) 0xb7f1273e in clone () at ../sysdeps/unix/sysv/linux/i386/clone.S:130
Thread 4 (Thread 0xb76d5b70 (LWP 6221)):
[#0](https://code.videolan.org/videolan/vlc/-/issues/0) 0xb7f04edc in *__GI___poll (fds=0xb7f87ff4, fds@entry=0xb76d5270,
nfds=nfds@entry=2, timeout=timeout@entry=-1)
at ../sysdeps/unix/sysv/linux/poll.c:87
[#1](https://code.videolan.org/videolan/vlc/-/issues/1) 0xb780e108 in Run (p_intf=0x80d9cd8)
at ../../../../modules/control/dbus/dbus.c:788
[#2](https://code.videolan.org/videolan/vlc/-/issues/2) 0xb7d7596d in RunInterface (p_this=0x80d9cd8)
at ../../src/interface/interface.c:203
[#3](https://code.videolan.org/videolan/vlc/-/issues/3) 0xb7f96954 in start_thread (arg=0xb76d5b70) at pthread_create.c:304
[#4](https://code.videolan.org/videolan/vlc/-/issues/4) 0xb7f1273e in clone () at ../sysdeps/unix/sysv/linux/i386/clone.S:130
Thread 2 (Thread 0xb7939b70 (LWP 6219)):
[#0](https://code.videolan.org/videolan/vlc/-/issues/0) 0xb7f9aea5 in __pthread_cond_wait (cond=0x80f3cf4, mutex=0x80f3cdc)
at pthread_cond_wait.c:153
[#1](https://code.videolan.org/videolan/vlc/-/issues/1) 0xb7df8ba3 in vlc_cond_wait (p_condvar=p_condvar@entry=0x80f3cf4,
p_mutex=p_mutex@entry=0x80f3cdc) at ../../src/posix/thread.c:431
[#2](https://code.videolan.org/videolan/vlc/-/issues/2) 0xb7d77486 in Thread (data=0x80f3c18) at ../../src/playlist/thread.c:587
[#3](https://code.videolan.org/videolan/vlc/-/issues/3) 0xb7f96954 in start_thread (arg=0xb7939b70) at pthread_create.c:304
[#4](https://code.videolan.org/videolan/vlc/-/issues/4) 0xb7f1273e in clone () at ../sysdeps/unix/sysv/linux/i386/clone.S:130
Thread 1 (Thread 0xb7cd26d0 (LWP 6216)):
[#0](https://code.videolan.org/videolan/vlc/-/issues/0) 0xb7f9ecc8 in do_sigwait (set=0xbffff0f4, sig=<optimized out>)
at ../nptl/sysdeps/unix/sysv/linux/../../../../../sysdeps/unix/sysv/linux/sigwait.c:63
[#1](https://code.videolan.org/videolan/vlc/-/issues/1) 0xb7f9ed60 in __sigwait (set=set@entry=0xbffff0f4,
sig=sig@entry=0xbffff0f0)
at ../nptl/sysdeps/unix/sysv/linux/../../../../../sysdeps/unix/sysv/linux/sigwait.c:100
[#2](https://code.videolan.org/videolan/vlc/-/issues/2) 0x0804913c in main (i_argc=<optimized out>, ppsz_argv=<optimized out>)
at ../../bin/vlc.c:224
Note that the file plays fine in ffplay (which selects the clear program by default) or with VLC if the program is selected explicitly: --program=200