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

[Omega] Kodi is unable to exit cleanly when certains addons are enabled #25114

Closed
1 of 7 tasks
rien333 opened this issue May 3, 2024 · 7 comments
Closed
1 of 7 tasks
Labels
Triage: Needed (managed by bot!) issue that was just created and needs someone looking at it

Comments

@rien333
Copy link

rien333 commented May 3, 2024

Bug report

Describe the bug

After having upgraded to Omega, I'm having trouble getting kodi to exit gracefully. That is, after quiting kodi from the UI/terminal/remote Android app/with kodi-send -a 'Shutdown()', kodi hangs and must be quit forcefully, i.e. by sending it a SIGKILL signal.

I narrowed down the problem to a few specific addons (netflix, twitch, and youtube). When at least one of these addons is enabled, kodi fails to exit. When all of these addons are disabled, kodi is able to exit normally. For completeness sake, I should mention that the common plugin cache and the 'kodi version check' addons seemed to produce the same behavior (though I haven't experimented with them a lot). One possible through line, here, is that all/most of these addons are launched when kodi launches. (edit: I've further narrowed down the problem to python 3.12)

Obviously, I initially contacted the relevant addon developers (see anxdpanic/plugin.video.youtube#738 and CastagnaIT/plugin.video.netflix#1697) , all the more because multiple forum posts indicated that addons are typically to blame for this type of problem (see e.g. this and this one). However, one addon dev redirected me here, as my logs indicate that their addon does indeed terminate correctly (running info threads in gdb seems to corroborate this observation, as the remaining threads when the program finally enters CDRMUtils::RestoreOriginalMode are "Announce", "Lirc", and "kodi.bin"). There's something to be said for the suggestion that the problem is not entirely on the addon developers, as it is conspicuous that multiple addons have stopped working simultaneously. (of course, the problem could theoretically also be something I or the Arch linux devs did)

Stack and thread info with one of the problematic addons enabled

Here's some info I generated by poking around in gdb. This information was generated with one of the problematic addons enabled. Further below, I provide the same information, but without any of these addons enabled (in which case kodi can exit normally).

From my naive point of view, the problem seems to be some kind of mutex deadlock. At least, there seem to be a bunch of threads just "idly" waiting around.

A list of all the threads:

(gdb) info threads
  Id   Target Id                                           Frame 
* 1    Thread 0x7ffff0fb4b80 (LWP 225526) "kodi.bin"       0x00007ffff58a68d9 in __futex_abstimed_wait_common64 (private=<optimized out>, cancel=true, abstime=0x0, op=393, expected=0, futex_word=0x7fff901095b0) at futex-internal.c:57
  2    Thread 0x7ffff09ff6c0 (LWP 225531) "Announce"       0x00007ffff58a68d9 in __futex_abstimed_wait_common64 (private=0, cancel=true, abstime=0x0, op=393, expected=0, futex_word=0x55555a449808) at futex-internal.c:57
  3    Thread 0x7fffebfff6c0 (LWP 225532) "Lirc"           0x00007ffff58a68d9 in __futex_abstimed_wait_common64 (private=0, cancel=true, abstime=0x7fffebffe4e0, op=137, expected=0, futex_word=0x55555a4279d8) at futex-internal.c:57
  39   Thread 0x7fff8bfff6c0 (LWP 225589) "kodi.bin"       0x00007ffff591d9ed in __GI___poll (fds=fds@entry=0x7fff84000b70, nfds=nfds@entry=2, timeout=timeout@entry=-1) at ../sysdeps/unix/sysv/linux/poll.c:29

Heres' a list of each threads' stack, after breaking on CDRMUtils::RestoreOriginalMode and having advanced the main thread ("kodi.bin") using (gdb) next until nothing happens anymore. I am not sure if these are useful, so please guide in me in what info I need to provide:

Thread number 1 ("kobi.bin")
(gdb) info stack
#0  0x00007ffff58a68d9 in __futex_abstimed_wait_common64
    (private=<optimized out>, cancel=true, abstime=0x0, op=393, expected=0, futex_word=0x7fff901095b0) at futex-internal.c:57
#1  __futex_abstimed_wait_common
    (futex_word=futex_word@entry=0x7fff901095b0, expected=expected@entry=0, clockid=clockid@entry=0, abstime=abstime@entry=0x0, private=<optimized out>, cancel=cancel@entry=true) at futex-internal.c:87
#2  0x00007ffff58a695f in __GI___futex_abstimed_wait_cancelable64
    (futex_word=futex_word@entry=0x7fff901095b0, expected=expected@entry=0, clockid=clockid@entry=0, abstime=abstime@entry=0x0, private=<optimized out>) at futex-internal.c:139
#3  0x00007ffff58b240f in do_futex_wait (sem=sem@entry=0x7fff901095b0, abstime=0x0, clockid=0)
    at /usr/src/debug/glibc/glibc/nptl/sem_waitcommon.c:111
#4  0x00007ffff58b24a8 in __new_sem_wait_slow64 (sem=sem@entry=0x7fff901095b0, abstime=0x0, clockid=0)
    at /usr/src/debug/glibc/glibc/nptl/sem_waitcommon.c:183
#5  0x00007ffff58b252d in __new_sem_wait (sem=sem@entry=0x7fff901095b0) at sem_wait.c:42
#6  0x00007ffff776b65e in PyThread_acquire_lock_timed (lock=0x7fff901095b0, microseconds=<optimized out>, intr_flag=1)
    at Python/thread_pthread.h:490
#7  0x00007ffff785652e in acquire_timed (lock=0x7fff901095b0, timeout=-1000000000) at ./Modules/_threadmodule.c:99
#8  0x00007ffff78811bf in lock_PyThread_acquire_lock (self=0x7fffa0792ec0, args=<optimized out>, kwds=<optimized out>)
    at ./Modules/_threadmodule.c:180
#9  0x00007ffff77a8ea2 in method_vectorcall_VARARGS_KEYWORDS
    (func=0x7fffc030ba10, args=0x7ffff0000098, nargsf=<optimized out>, kwnames=<optimized out>) at Objects/descrobject.c:365
#10 0x00007ffff779a844 in _PyObject_VectorcallTstate
    (kwnames=0x0, nargsf=9223372036854775809, args=0x7ffff0000098, callable=0x7fffc030ba10, tstate=0x7ffff7c22ae8 <_PyRuntime+459656>)
    at ./Include/internal/pycore_call.h:92
#11 PyObject_Vectorcall (callable=0x7fffc030ba10, args=0x7ffff0000098, nargsf=9223372036854775809, kwnames=0x0) at Objects/call.c:325
#12 0x00007ffff768bdfa in _PyEval_EvalFrameDefault (tstate=<optimized out>, frame=0x7ffff0000020, throwflag=<optimized out>)
    at Python/bytecodes.c:2706
#13 0x00007ffff7789e1a in _PyObject_VectorcallTstate
    (kwnames=0x0, nargsf=<optimized out>, args=0x7fffffffdee8, callable=0x7fffa07a02c0, tstate=0x7ffff7c22ae8 <_PyRuntime+459656>)
    at ./Include/internal/pycore_call.h:92
#14 PyObject_VectorcallMethod (name=<optimized out>, args=0x7fffffffdee8, nargsf=<optimized out>, kwnames=0x0) at Objects/call.c:887
#15 0x00007ffff787091d in PyObject_CallMethodNoArgs (name=0x7ffff7bbb590 <_PyRuntime+36400>, self=<optimized out>)
    at ./Include/cpython/abstract.h:94
#16 wait_for_thread_shutdown (tstate=0x7ffff7c22ae8 <_PyRuntime+459656>) at Python/pylifecycle.c:3007
#17 0x00007ffff785e2de in Py_FinalizeEx () at Python/pylifecycle.c:1800
#18 0x00005555560fb8fe in XBPython::~XBPython() ()
#19 0x00005555560fb9c9 in XBPython::~XBPython() ()
#20 0x0000555556a86063 in CServiceManager::DeinitStageOne() ()
#21 0x0000555556873a79 in CApplication::Cleanup() ()
#22 0x0000555556873f0f in CApplication::Run() ()
#23 0x0000555555f44b96 in main ()
Thread number 2 ("Announce")
(gdb) info stack
#0  0x00007ffff58a68d9 in __futex_abstimed_wait_common64 (private=0, cancel=true, abstime=0x0, op=393, expected=0, futex_word=0x55555a449808)
    at futex-internal.c:57
#1  __futex_abstimed_wait_common
    (futex_word=futex_word@entry=0x55555a449808, expected=expected@entry=0, clockid=clockid@entry=0, abstime=abstime@entry=0x0, private=private@entry=0, cancel=cancel@entry=true) at futex-internal.c:87
#2  0x00007ffff58a695f in __GI___futex_abstimed_wait_cancelable64
    (futex_word=futex_word@entry=0x55555a449808, expected=expected@entry=0, clockid=clockid@entry=0, abstime=abstime@entry=0x0, private=private@entry=0) at futex-internal.c:139
#3  0x00007ffff58a9299 in __pthread_cond_wait_common (abstime=0x0, clockid=0, mutex=<optimized out>, cond=0x55555a4497e0) at pthread_cond_wait.c:503
#4  ___pthread_cond_wait (cond=0x55555a4497e0, mutex=<optimized out>) at pthread_cond_wait.c:618
#5  0x00007ffff5ad4ec1 in __gthread_cond_wait (__mutex=<optimized out>, __cond=<optimized out>)
    at /usr/src/debug/gcc/gcc-build/x86_64-pc-linux-gnu/libstdc++-v3/include/x86_64-pc-linux-gnu/bits/gthr-default.h:865
#6  std::__condvar::wait (__m=<optimized out>, this=<optimized out>)
    at /usr/src/debug/gcc/gcc-build/x86_64-pc-linux-gnu/libstdc++-v3/include/bits/std_mutex.h:171
#7  std::condition_variable::wait (this=<optimized out>, __lock=<optimized out>)
    at /usr/src/debug/gcc/gcc/libstdc++-v3/src/c++11/condition_variable.cc:41
#8  0x00005555561030ff in void std::_V2::condition_variable_any::wait<XbmcThreads::CRecursiveMutex>(XbmcThreads::CRecursiveMutex&) ()
#9  0x0000555556ff5453 in ANNOUNCEMENT::CAnnouncementManager::Process() ()
#10 0x0000555556653b82 in CThread::Action() ()
#11 0x0000555556654616 in CThread::Create(bool)::{lambda(CThread*, std::promise<bool>)#1}::operator()(CThread*, std::promise<bool>) const [clone .isra.0] ()
#12 0x0000555556655392 in std::thread::_State_impl<std::thread::_Invoker<std::tuple<CThread::Create(bool)::{lambda(CThread*, std::promise<bool>)#1}, CThread*, std::promise<bool> > > >::_M_run() ()
#13 0x00007ffff5adcb63 in std::execute_native_thread_routine (__p=0x55555a439070) at /usr/src/debug/gcc/gcc/libstdc++-v3/src/c++11/thread.cc:104
#14 0x00007ffff58aa1cf in start_thread (arg=<optimized out>) at pthread_create.c:447
#15 0x00007ffff592b6ec in clone3 () at ../sysdeps/unix/sysv/linux/x86_64/clone3.S:78
Thread number 3 ("Lirc")
(gdb) info stack
#0  0x00007ffff58a68d9 in __futex_abstimed_wait_common64
    (private=0, cancel=true, abstime=0x7fffebffe4e0, op=137, expected=0, futex_word=0x55555a4279d8) at futex-internal.c:57
#1  __futex_abstimed_wait_common
    (futex_word=futex_word@entry=0x55555a4279d8, expected=expected@entry=0, clockid=clockid@entry=1, abstime=abstime@entry=0x7fffebffe4e0, private=private@entry=0, cancel=cancel@entry=true) at futex-internal.c:87
#2  0x00007ffff58a695f in __GI___futex_abstimed_wait_cancelable64
    (futex_word=futex_word@entry=0x55555a4279d8, expected=expected@entry=0, clockid=clockid@entry=1, abstime=abstime@entry=0x7fffebffe4e0, private=private@entry=0) at futex-internal.c:139
#3  0x00007ffff58a9922 in __pthread_cond_wait_common (abstime=<optimized out>, clockid=<optimized out>, mutex=<optimized out>, cond=0x55555a4279b0)
    at pthread_cond_wait.c:503
#4  ___pthread_cond_clockwait64 (abstime=<optimized out>, clockid=<optimized out>, mutex=<optimized out>, cond=0x55555a4279b0)
    at pthread_cond_wait.c:682
#5  ___pthread_cond_clockwait64 (cond=0x55555a4279b0, mutex=<optimized out>, clockid=<optimized out>, abstime=<optimized out>)
    at pthread_cond_wait.c:670
#6  0x00005555561dfaf2 in bool CEvent::Wait<long, std::ratio<1l, 1000l> >(std::chrono::duration<long, std::ratio<1l, 1000l> >) [clone .isra.0] ()
#7  0x00005555561e0eb6 in CLirc::Process() ()
#8  0x0000555556653b82 in CThread::Action() ()
#9  0x0000555556654616 in CThread::Create(bool)::{lambda(CThread*, std::promise<bool>)#1}::operator()(CThread*, std::promise<bool>) const [clone .isra.0] ()
#10 0x0000555556655392 in std::thread::_State_impl<std::thread::_Invoker<std::tuple<CThread::Create(bool)::{lambda(CThread*, std::promise<bool>)#1}, CThread*, std::promise<bool> > > >::_M_run() ()
#11 0x00007ffff5adcb63 in std::execute_native_thread_routine (__p=0x55555a44a220) at /usr/src/debug/gcc/gcc/libstdc++-v3/src/c++11/thread.cc:104
#12 0x00007ffff58aa1cf in start_thread (arg=<optimized out>) at pthread_create.c:447
#13 0x00007ffff592b6ec in clone3 () at ../sysdeps/unix/sysv/linux/x86_64/clone3.S:78
Thread numer 39 ("kodi.bin")
(gdb) info stack
#0  0x00007ffff591d9ed in __GI___poll (fds=fds@entry=0x7fff84000b70, nfds=nfds@entry=2, timeout=timeout@entry=-1)
    at ../sysdeps/unix/sysv/linux/poll.c:29
#1  0x00007ffff6ebe340 in poll
    (__timeout=-1, __nfds=2, __fds=0x7fff84000b70, __fds=<optimized out>, __nfds=<optimized out>, __timeout=<optimized out>)
    at /usr/include/bits/poll2.h:39
#2  poll_func (ufds=0x7fff84000b70, nfds=2, timeout=-1, userdata=0x55555c2d7990) at /usr/src/debug/avahi/avahi/avahi-common/thread-watch.c:56
#3  0x00007ffff6ec0ed1 in avahi_simple_poll_run (s=0x55555c2c7e00) at /usr/src/debug/avahi/avahi/avahi-common/simple-watch.c:527
#4  avahi_simple_poll_run (s=s@entry=0x55555c2c7e00) at /usr/src/debug/avahi/avahi/avahi-common/simple-watch.c:518
#5  0x00007ffff6ec10b1 in avahi_simple_poll_iterate (timeout=<optimized out>, s=0x55555c2c7e00)
    at /usr/src/debug/avahi/avahi/avahi-common/simple-watch.c:602
#6  avahi_simple_poll_iterate (s=s@entry=0x55555c2c7e00, timeout=timeout@entry=-1) at /usr/src/debug/avahi/avahi/avahi-common/simple-watch.c:596
#7  0x00007ffff6ec12c6 in avahi_simple_poll_loop (s=0x55555c2c7e00) at /usr/src/debug/avahi/avahi/avahi-common/simple-watch.c:646
#8  0x00007ffff6ec134f in thread (userdata=0x55555c2d7980) at /usr/src/debug/avahi/avahi/avahi-common/thread-watch.c:71
#9  0x00007ffff58aa1cf in start_thread (arg=<optimized out>) at pthread_create.c:447
#10 0x00007ffff592b6ec in clone3 () at ../sysdeps/unix/sysv/linux/x86_64/clone3.S:78

Stack and thread info without any of the problematic addons enabled

Thread info:

Thread 1 "kodi.bin" hit Breakpoint 1, 0x0000555557227000 in KODI::WINDOWING::GBM::CDRMUtils::RestoreOriginalMode() ()
(gdb) info threads
  Id   Target Id                                     Frame 
* 1    Thread 0x7ffff0fb4b80 (LWP 226415) "kodi.bin" 0x0000555557227000 in KODI::WINDOWING::GBM::CDRMUtils::RestoreOriginalMode() ()
  2    Thread 0x7ffff09ff6c0 (LWP 226421) "Announce" 0x00007ffff58a68d9 in __futex_abstimed_wait_common64 (private=0, cancel=true, abstime=0x0, op=393, expected=0, futex_word=0x55555a4497a8) at futex-internal.c:57
  5    Thread 0x7fffeaffd6c0 (LWP 226424) "Lirc"     0x00007ffff58a68d9 in __futex_abstimed_wait_common64 (private=0, cancel=true, abstime=0x7fffeaffc4e0, op=137, expected=0, futex_word=0x55555a427978) at futex-internal.c:57
  25   Thread 0x7fff8ffff6c0 (LWP 226461) "kodi.bin" 0x00007ffff591d9ed in __GI___poll (fds=fds@entry=0x7fff88000b70, nfds=nfds@entry=2, timeout=timeout@entry=-1) at ../sysdeps/unix/sysv/linux/poll.c:29

The application behaves differently without any of the problematic addons enabled, so I just (gdb) next on the main thread until it exits. Here is the interactive session, starting from the same breakpoint:

Interactive gdb session
Thread 1 "kodi.bin" hit Breakpoint 1, 0x0000555557227000 in KODI::WINDOWING::GBM::CDRMUtils::RestoreOriginalMode() ()
(gdb) n
Single stepping until exit from function _ZN4KODI9WINDOWING3GBM9CDRMUtils19RestoreOriginalModeEv,
which has no line number information.

0x0000555557227329 in KODI::WINDOWING::GBM::CDRMUtils::DestroyDrm() ()
(gdb) 
Single stepping until exit from function _ZN4KODI9WINDOWING3GBM9CDRMUtils10DestroyDrmEv,
which has no line number information.
0x00005555572273b1 in KODI::WINDOWING::GBM::CDRMUtils::~CDRMUtils() ()
(gdb) n
Single stepping until exit from function _ZN4KODI9WINDOWING3GBM9CDRMUtilsD2Ev,
which has no line number information.

^C
Thread 2 "Announce" received signal SIGINT, Interrupt.
[Switching to Thread 0x7ffff09ff6c0 (LWP 226549)] // switches to thread 2 for some reason 
0x00007ffff58a68d9 in __futex_abstimed_wait_common64 (private=0, cancel=true, abstime=0x0, op=393, expected=0, 
    futex_word=0x55555a4497a8) at futex-internal.c:57
57          return INTERNAL_SYSCALL_CANCEL (futex_time64, futex_word, op, expected,
(gdb) info threads
  Id   Target Id                                     Frame 
  1    Thread 0x7ffff0fb4b80 (LWP 226544) "kodi.bin" 0x000055555722772a in KODI::WINDOWING::GBM::CDRMUtils::~CDRMUtils() ()
* 2    Thread 0x7ffff09ff6c0 (LWP 226549) "Announce" 0x00007ffff58a68d9 in __futex_abstimed_wait_common64 (private=0, cancel=true, 
    abstime=0x0, op=393, expected=0, futex_word=0x55555a4497a8) at futex-internal.c:57
  5    Thread 0x7fffeaffd6c0 (LWP 226552) "Lirc"     0x00007ffff58a68d9 in __futex_abstimed_wait_common64 (private=0, cancel=true, 
    abstime=0x7fffeaffc4e0, op=137, expected=0, futex_word=0x55555a427978) at futex-internal.c:57
  25   Thread 0x7fff8ffff6c0 (LWP 226590) "kodi.bin" 0x00007ffff591d9ed in __GI___poll (fds=fds@entry=0x7fff88000b70, 
    nfds=nfds@entry=2, timeout=timeout@entry=-1) at ../sysdeps/unix/sysv/linux/poll.c:29
(gdb) thread 1
[Switching to thread 1 (Thread 0x7ffff0fb4b80 (LWP 226544))]
#0  0x000055555722772a in KODI::WINDOWING::GBM::CDRMUtils::~CDRMUtils() ()
(gdb) n
Single stepping until exit from function _ZN4KODI9WINDOWING3GBM9CDRMUtilsD2Ev,
which has no line number information.
operator delete (ptr=0x55555a785290) at /usr/src/debug/gcc/gcc/libstdc++-v3/libsupc++/del_ops.cc:32
Downloading source file /usr/src/debug/gcc/gcc/libstdc++-v3/libsupc++/del_ops.cc
warning: 32     /usr/src/debug/gcc/gcc/libstdc++-v3/libsupc++/del_ops.cc: No such file or directory                                      (gdb) n
33      in /usr/src/debug/gcc/gcc/libstdc++-v3/libsupc++/del_ops.cc
(gdb) 
operator delete (ptr=0x55555a785290) at /usr/src/debug/gcc/gcc/libstdc++-v3/libsupc++/del_op.cc:48
Downloading source file /usr/src/debug/gcc/gcc/libstdc++-v3/libsupc++/del_op.cc
warning: 48     /usr/src/debug/gcc/gcc/libstdc++-v3/libsupc++/del_op.cc: No such file or directory                                       (gdb) n
49      in /usr/src/debug/gcc/gcc/libstdc++-v3/libsupc++/del_op.cc
(gdb) n
__GI___libc_free (mem=0x55555a785290) at malloc.c:3359
3359    {                                                                                                                                (gdb) n
3363      if (mem == 0)                              /* free(0) has no effect */
(gdb) n
3371      int err = errno;
(gdb) n
3375      if (chunk_is_mmapped (p))                       /* release mmapped memory. */
(gdb) 
3392          MAYBE_INIT_TCACHE ();
(gdb) 
3397          ar_ptr = arena_for_chunk (p);
(gdb) 
3398          _int_free (ar_ptr, p, 0);
(gdb) 
3401      __set_errno (err);
(gdb) 
0x00005555572116c2 in KODI::WINDOWING::GBM::CWinSystemGbm::~CWinSystemGbm() ()
(gdb) 
Single stepping until exit from function _ZN4KODI9WINDOWING3GBM13CWinSystemGbmD2Ev,
which has no line number information.
0x00005555565097a0 in CWinSystemBase::~CWinSystemBase() ()
(gdb) 
Single stepping until exit from function _ZN14CWinSystemBaseD2Ev,
which has no line number information.
0x000055555721adbb in KODI::WINDOWING::GBM::CWinSystemGbmGLContext::~CWinSystemGbmGLContext() ()
(gdb) 
Single stepping until exit from function _ZN4KODI9WINDOWING3GBM22CWinSystemGbmGLContextD0Ev,
which has no line number information.
operator delete (ptr=0x55555a518e50) at /usr/src/debug/gcc/gcc/libstdc++-v3/libsupc++/del_ops.cc:32
warning: 32     /usr/src/debug/gcc/gcc/libstdc++-v3/libsupc++/del_ops.cc: No such file or directory                                      (gdb) 
33      in /usr/src/debug/gcc/gcc/libstdc++-v3/libsupc++/del_ops.cc
(gdb) 
operator delete (ptr=0x55555a518e50) at /usr/src/debug/gcc/gcc/libstdc++-v3/libsupc++/del_op.cc:48
warning: 48     /usr/src/debug/gcc/gcc/libstdc++-v3/libsupc++/del_op.cc: No such file or directory                                       (gdb) 
49      in /usr/src/debug/gcc/gcc/libstdc++-v3/libsupc++/del_op.cc
(gdb) 
__GI___libc_free (mem=0x55555a518e50) at malloc.c:3359
3359    {
(gdb) 
3363      if (mem == 0)                              /* free(0) has no effect */
(gdb) 
3371      int err = errno;
(gdb) 
3375      if (chunk_is_mmapped (p))                       /* release mmapped memory. */
(gdb) 
3392          MAYBE_INIT_TCACHE ();
(gdb) 
3397          ar_ptr = arena_for_chunk (p);
(gdb) 
3398          _int_free (ar_ptr, p, 0);
(gdb) 
3401      __set_errno (err);
(gdb) 
0x0000555556873a67 in CApplication::Cleanup() ()
(gdb) 
Single stepping until exit from function _ZN12CApplication7CleanupEv,
which has no line number information.
[Thread 0x7fffeaffd6c0 (LWP 226552) exited]
[Thread 0x7ffff09ff6c0 (LWP 226549) exited]

0x0000555556873f0f in CApplication::Run() ()
(gdb) 
Single stepping until exit from function _ZN12CApplication3RunEv,
which has no line number information.
0x0000555555f44b96 in main ()
(gdb) 
Single stepping until exit from function main,
which has no line number information.
__libc_start_call_main (main=main@entry=0x555555f44a80 <main>, argc=argc@entry=1, argv=argv@entry=0x7fffffffe578)
    at ../sysdeps/nptl/libc_start_call_main.h:74
Downloading source file /usr/src/debug/glibc/glibc/csu/../sysdeps/nptl/libc_start_call_main.h
warning: Source file is more recent than executable.
74        exit (result);
(gdb) 
[Thread 0x7ffff0fb4b80 (LWP 226544) exited]
[Thread 0x7fff8ffff6c0 (LWP 226590) exited]
[New process 226544]
[Inferior 1 (process 226544) exited normally]
(gdb) 
The program is not being run.
(gdb) 

Expected Behavior

The kodi process exits swiftly and cleanly when I quit from the UI, or send it a SIGTERM signal.

Actual Behavior

Kodi hangs infinitely, and can only be killed with kill -9 [PID]

Possible Fix

No idea. Honestly, I'm kind of worried I'm going to be directed back to the addon developers 😅

To Reproduce

  1. Using python 3.12 as kodi's python backend
  2. Install the youtube/twitch/netflix addon from kodi's official repositories.
  3. Make sure one of these addons is running, and exit kodi.

Debuglog

The debuglog can be found here:

https://paste.kodi.tv/tikigugaca.kodi

(I forgot to disable advancedsettings.xml and my custom kodi skin, but I have determined numerous times that those don't impact the problem)

Screenshots

N/A

Additional context or screenshots (if appropriate)

N/A

Your Environment

Used Operating system:

  • Android

  • iOS

  • tvOS

  • Linux

  • macOS

  • Windows

  • Windows UWP

  • Operating system version/name: Arch Linux (updated)

  • Kodi version: v21 (Omega)

  • Python version: 3.12

@xbmc-gh-bot xbmc-gh-bot bot added the Triage: Needed (managed by bot!) issue that was just created and needs someone looking at it label May 3, 2024
@rien333
Copy link
Author

rien333 commented May 3, 2024

Here's the output of valgrind. I was asked to provide this by one of the addon developer. (again, excuse my if my invocation of valgrind is incorrect)

valgrind output (with addons enabled)
$ DEBUGINFOD_URLS=https://debuginfod.archlinux.org valgrind --leak-check=full --show-leak-kinds=all --track-origins=yes   /usr/lib/kodi/kodi.bin`
==225846== Memcheck, a memory error detector
==225846== Copyright (C) 2002-2024, and GNU GPL'd, by Julian Seward et al.
==225846== Using Valgrind-3.23.0 and LibVEX; rerun with -h for copyright info
==225846== Command: /usr/lib/kodi/kodi.bin
==225846== 
==225846== Syscall param ioctl(generic) points to unaddressable byte(s)
==225846==    at 0x7CFF00D: ioctl (ioctl.c:36)
==225846==    by 0xD95597: open_restricted(char const*, int, void*) (LibInputHandler.cpp:39)
==225846==    by 0x66933C5: UnknownInlinedFun (libinput.c:2047)
==225846==    by 0x66933C5: evdev_device_create (evdev.c:2407)
==225846==    by 0x66A5F53: device_added (udev-seat.c:121)
==225846==    by 0x66A632E: UnknownInlinedFun (udev-seat.c:202)
==225846==    by 0x66A632E: udev_input_enable (udev-seat.c:315)
==225846==    by 0x66A64B1: libinput_udev_assign_seat (udev-seat.c:452)
==225846==    by 0xD97354: CLibInputHandler::CLibInputHandler() (LibInputHandler.cpp:91)
==225846==    by 0x1DC581A: KODI::WINDOWING::GBM::CWinSystemGbm::CWinSystemGbm() (WinSystemGbm.cpp:91)
==225846==    by 0x1DCDBFD: KODI::WINDOWING::GBM::CWinSystemGbmGLContext::CWinSystemGbmGLContext() (WinSystemGbmEGLContext.h:40)
==225846==    by 0x1DCDCBF: KODI::WINDOWING::GBM::CWinSystemGbmGLContext::CreateWinSystem() (unique_ptr.h:1070)
==225846==    by 0x1DCEC0A: std::_Function_handler<std::unique_ptr<CWinSystemBase, std::default_delete<CWinSystemBase> > (), std::unique_ptr<CWinSystemBase, std::default_delete<CWinSystemBase> > (*)()>::_M_invoke(std::_Any_data const&) (invoke.h:61)
==225846==    by 0x10BCF6D: KODI::WINDOWING::CWindowSystemFactory::CreateWindowSystem(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&) (std_function.h:591)
==225846==  Address 0x1 is not stack'd, malloc'd or (recently) free'd
==225846== 
 ==225846== Syscall param ioctl(generic) points to uninitialised byte(s)
==225846==    at 0x7CFF00D: ioctl (ioctl.c:36)
==225846==    by 0x7599310: drmIoctl (xf86drm.c:704)
==225846==    by 0x1E0E5B23: UnknownInlinedFun (xf86drm.c:1016)
==225846==    by 0x1E0E5B23: mos_gem_bo_export_to_prime(mos_linux_bo*, int*) [clone .lto_priv.0] (mos_bufmgr.c:3569)
==225846==    by 0x1E27ABAA: UnknownInlinedFun (mos_bufmgr_api.c:899)
==225846==    by 0x1E27ABAA: DdiMedia_ExportSurfaceHandle(VADriverContext*, unsigned int, unsigned int, unsigned int, void*) (media_libva.cpp:7220)
==225846==    by 0x5F56AFC: vaExportSurfaceHandle (va.c:1580)
==225846==    by 0xDC1C80: VAAPI::CVaapi2Texture::TestEsh(void*, void*, unsigned int, int) (VaapiEGL.cpp:633)
==225846==    by 0xDC1DAB: VAAPI::CVaapi2Texture::TestInterop(void*, void*, bool&, bool&) (VaapiEGL.cpp:690)
==225846==    by 0xDC0BAD: CRendererVAAPIGL::Register(VAAPI::IVaapiWinSystem*, void*, void*, bool&, bool&) (RendererVAAPIGL.cpp:46)
==225846==    by 0x1DCD9BD: KODI::WINDOWING::GBM::CWinSystemGbmGLContext::InitWindowSystem() (WinSystemGbmGLContext.cpp:67)
==225846==    by 0x142693B: CApplication::CreateGUI() (Application.cpp:488)
==225846==    by 0x1250159: XBMC_Run (xbmc.cpp:36)
==225846==    by 0xAF8B95: main (main.cpp:70)
==225846==  Address 0x1ffefffa54 is on thread 1's stack
==225846==  in frame #2, created by mos_gem_bo_export_to_prime(mos_linux_bo*, int*) [clone .lto_priv.0] (xf86drm.c:3560)
==225846==  Uninitialised value was created by a stack allocation
==225846==    at 0x1E0E5AB0: mos_gem_bo_export_to_prime(mos_linux_bo*, int*) [clone .lto_priv.0] (mos_bufmgr.c:3560)
==225846== 

I will provide the output of valgrind without addons enabled later on.

@rien333
Copy link
Author

rien333 commented May 5, 2024

New development: I cannot reproduce any longer if I downgrade to python 3.11! So, maybe some threading related code changed in 3.12?

@bacon-cheeseburger
Copy link

@rien333 It seems python 3.12 has a bug thats impacting a lot of things. python/cpython#118618

@rien333
Copy link
Author

rien333 commented May 13, 2024

Right, will close this if it indeed turns out that python needs to do all the fixing. I'll be testing whenever an official fix lands.

@obaterspok
Copy link

This is a duplicate of #24440

@rien333
Copy link
Author

rien333 commented May 14, 2024

@obaterspok Indeed, this issue may well be related to #24440/the python issue described therein. However, since I'm not actually experiencing a crash (just a hang), I'm not entirely sure if it's a duplicate just yet.

However, if I can no longer reproduce this with python fix that is being thrown around there, I'll surely close this!

@rien333
Copy link
Author

rien333 commented May 16, 2024

Confirmed this as a python issue - applying this patch fixes my issue.

Sorry for the noise!

@rien333 rien333 closed this as completed May 16, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Triage: Needed (managed by bot!) issue that was just created and needs someone looking at it
Projects
None yet
Development

No branches or pull requests

3 participants