Kodi crashes as soon as any addon is started

Hello all,
this is very strange. I’ve just updated my media server that runs Kodi to NixOS 21.11. Now, when I start an addon Kodi crashes with a segfault, This is the log collected by systemd:

Mar 01 00:20:42 giskard kernel: LanguageInvoker[78666]: segfault at 8 ip 00007fe0769110ac sp 00007fdff3ffb180 error 4 in libpython3.9.so.1.0[7fe07>
Mar 01 00:20:42 giskard kernel: Code: fe ff ff 0f 1f 00 e8 23 7f e8 ff e9 d5 fe ff ff 66 66 2e 0f 1f 84 00 00 00 00 00 0f 1f 00 55 48 8b 4f f0 48 >

It happens every time an addon is started, but the player works well when asked to play something from the filesystem.

then a coredump is generated, but it doesn’t tell so much about the cause of this error.

The server configuration can be found here: Alberto / giskard-configuration · GitLab
I searched for similar errors but I did not find anything. Do you have any clue?

Incredibly, switching from the latest kernel to the standard one did the trick

I’m glad there issue is resolved… strange, though. I’m curious if anyone has any thoughts on that.

I was astonished because I do use the latest kernel (a 5.16.10 as of now) on my laptop already, together with the same version of kodi and it works well.
What is different between the two machines is the distro ( 21.11 on the server, unstable on the laptop), the processor ( an Intel Pentium J4205 on the server and a Intel Core i7-1165G7 on the laptop), and the display system (X11 on the server and Wayland on the laptop).

I have the same problem. Sadly switching from latest kernel to the default kernel didn’t help.

I’m using kodi-x11 on nixos-unstable.

Maybe trying with the stable kernel from 21.11 will help? What processor does it have? (Not that I found any specific correlation with the cpu type)

I switched to 21.11 with latest kernel and there it works most of the time to be usable (but sometimes it still crashes with the same error). I still need to test it with the 21.11 default kernel.

It’s an AMD Ryzen 2200U.

Which addons do you have installed? How did you instead each addon: imperatively or declaratively? Is it really when any addon runs, or just when you launch one? (A number of addons automatically run in the background).

Hi @aanderse, in my case the addon is RaiPlay and I’ve installed it imperatively from the official repository. I’ve other addons all of them installed imperatively. Kody crashed when I lounched them from the “addons” menu, and every time Kodi segfaulted in libpython3.9.so right until I removed the kernel package configuration.

In my case it depends.
I mainly use jellyfin. It doesn’t make a difference if it’s imperatively or declaratevily installed it behaves the same in both cases. On unstable as soon as i try to start anything kodi immediately crashes and sometimes it crashes randomly (i assume some addon does something in the background).

When i watch tv on kodi it’s through the tvheadend addon, but this works completely fine in any cases (propably since its a binary and not a python addon).

on 21.11 it’s way harder to get it reliably crashing. I haven’t found a reproducable crash yet. it seems pretty random to me. Most of the crashes i had there was directly after the media stopped playing.

my configs are here:

the relevant files for my mediacenter device is fulbert.nix and usecases/htpc.nix

I could get it working again (at least most of the time) by deleting my ~/.kodi folder.

I still don’t know the root of this problem. but this explains why some people are affected by this problem and others not.

I think i now found the root cause of this problem.

for some kodi addons a python cache is generated in the ~/.kodi folder. e.g. kodi/addons/script.embuary.helper/resources/lib/pycache/library.cpython-39.opt-1.pyc

i had several hundreds of them for several python versions. After deleting all the *.pyc files in my ~/.kodi folder kodi didn’t crash anymore at all.

i don’t know the details about the python cache files. my guess is they contain some paths or something, so they break when python modules or cpython gets updated or something like this.

this would also explain why it’s hard to reproduce this error.