Due to an influx of spam, we have had to temporarily disable account registrations. Please write an email to accountsupport@archlinux.org, with your desired username, if you want to get access. Sorry for the inconvenience.
Not sure whether to file this under kodi or python; kodi segfaults on exit, backtrace refers to libpython.
This happens since either kodi 21 or python 3.12 (both packages released in April).
Additional info:
package version(s):
kodi 21.0-4python 3.12.3-1
config and/or log files:
Process 2826 (kodi.bin) of user 420 dumped core.Core was generated by `/usr/lib/kodi/kodi.bin --standalone'.Program terminated with signal SIGSEGV, Segmentation fault.#0 0x0000758146172d11 in _PyGCHead_SET_PREV (prev=<optimized out>, gc=<optimized out>) at ./Include/internal/pycore_gc.h:7474 gc->_gc_prev = ((gc->_gc_prev & ~_PyGC_PREV_MASK) | uprev);[Current thread is 1 (Thread 0x758102a006c0 (LWP 2856))](gdb) backtrace#0 0x0000758146172d11 in _PyGCHead_SET_PREV (prev=<optimized out>, gc=<optimized out>) at ./Include/internal/pycore_gc.h:74#1 _PyObject_GC_UNTRACK (op=0x758103f5e890) at ./Include/internal/pycore_object.h:247#2 PyObject_GC_UnTrack (op_raw=0x758103f5e890) at Modules/gcmodule.c:2242#3 0x0000758146274f7b in module_dealloc (m=0x758103f5e890) at Objects/moduleobject.c:709#4 0x0000758146188437 in _Py_Dealloc (op=<optimized out>) at Objects/object.c:2625#5 Py_DECREF (op=<optimized out>) at ./Include/object.h:705#6 Py_XDECREF (op=<optimized out>) at ./Include/object.h:798#7 Py_XDECREF (op=<optimized out>) at ./Include/object.h:795#8 meth_dealloc (m=0x758103f5f740) at Objects/methodobject.c:170#9 0x00007581461774e1 in _Py_Dealloc (op=0x758103f5f740) at Objects/object.c:2625#10 Py_DECREF (op=0x758103f5f740) at ./Include/object.h:705#11 Py_XDECREF (op=0x758103f5f740) at ./Include/object.h:798#12 insertdict (interp=0x758134522010, mp=mp@entry=0x75810cda7980, key=key@entry=0x758103f67d30, hash=hash@entry=-2078559206695431833, value=value@entry=0x7581465a9de0 <_Py_NoneStruct>) at Objects/dictobject.c:1319#13 0x00007581461faf01 in _PyDict_SetItem_Take2 (value=0x7581465a9de0 <_Py_NoneStruct>, key=<optimized out>, mp=<optimized out>) at Objects/dictobject.c:1865#14 PyDict_SetItem (value=0x7581465a9de0 <_Py_NoneStruct>, key=<optimized out>, op=<optimized out>) at Objects/dictobject.c:1883#15 _PyModule_ClearDict (d=0x75810cda7980) at Objects/moduleobject.c:656#16 0x0000758146274b4c in finalize_modules_clear_weaklist (verbose=0, weaklist=0x7580d7dd3340, interp=0x758134522010) at Python/pylifecycle.c:1526#17 finalize_modules (tstate=tstate@entry=0x75813457f930) at Python/pylifecycle.c:1609#18 0x00007581462803fe in Py_EndInterpreter (tstate=0x75813457f930) at Python/pylifecycle.c:2199#19 0x000061870dab0388 in CPythonInvoker::onExecutionDone() ()#20 0x000061870e5bac1d in non-virtual thunk to CLanguageInvokerThread::OnExit() ()#21 0x000061870deb9b90 in CThread::Action() ()#22 0x000061870dec3304 in ??? ()#23 0x00007581444e0c84 in std::execute_native_thread_routine (__p=0x61872e34d160) at /usr/src/debug/gcc/gcc/libstdc++-v3/src/c++11/thread.cc:104#24 0x00007581442a6ded in start_thread (arg=<optimized out>) at pthread_create.c:447#25 0x000075814432a0dc in clone3 () at ../sysdeps/unix/sysv/linux/x86_64/clone3.S:78
Please let me know which further information to provide.
To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information
Child items ...
Show closed items
Linked items 0
Link issues together to show that they're related or that one is blocking others.
Learn more.
Thanks for verifying. I cannot test 3.12.4-1 + the PR you referenced for some time. Do you know that applying it and not applying https://github.com/python/cpython/pull/118618 which I did verify as fixing this issue does in fact, fix the issue?
I also applied two of the three commits from that PR (omitting the third which modifies Doc/data/python3.12.abi since it needs a rebase) to python-3.12.4-1 and can confirm your finding that the it fixes the original issue in this report with Kodi.
I cannot comment on the gitlab bug (account registration closed). Based on that call stack dump, I would guess it's a similar problem to what WeeChat is encountering. The traceback is starting from Py_EndInterpreter and ending in _PyObject_GC_UNTRACK. I would suggest calling clear on the kodi module(s) before calling Py_EndInterpreter. Module functions have reference cycles and they make interpreter cleanup very complex. There could be a bug in Python or there could be a bug in kodi (e.g. incorrect refcnt inc/dec somewhere). Adding a module dict clear might fix it. See the gist linked from the comment below: https://github.com/python/cpython/issues/116510#issuecomment-2198359199
@eworm - Thought what I posted above did (I had the kodi debug package installed at the time). I am launching kodi from a systemd service so not directly using gbd. Would providing the 23.2M file from this be helpful?
# coredumpctl list TIME PID UID GID SIG COREFILE EXE SIZESat 2024-07-06 04:27:48 EDT 205414 989 989 SIGSEGV present /usr/lib/kodi/kodi.bin 23.2M
@gromit - I emailed you the file to your private email not knowing if the coredump may expose some personal information due to kodi plugins debugging who knows what from their config files. Did you receive?
After quite a lot of debugging work, I think I found the bug causing Weechat to crash. It looks similar to the crash that Kodi is producing so I hope the same fix will work. See:
Many thanks for the time and effort you spent debugging the crashes, Neil. I can confirm that applying both of the commits to 3.12.6 is required to prevent the bug with Kodi.
As with Weechat, I would suggest looking into if you can set m_size = 0 for the extension(s) that Kodi creates. You might need to use separate module state but it's also possible it just works by changing the -1 to 0 in the module spec.
@nascheme - I am unfamiliar with what you're suggesting/not a python person. Can you be more specific? Also, do you recommend doing so with the python-3.12.6-1 repo package or with the package I patches with the two PRs you linked above?
The simple thing to do is wait for Python to get the fixes. If you want to avoid the bugs with a Kodi source change, it's possible you can change the "-1" on the line following "static struct PyModuleDef createModule
" to be "0" instead. That's the "m_size" value of the module def. Using 0 marks the Python extension module created by Kodo as being safe for multi-init and would avoid these two bugs. However, I'm not sure what Kodi is doing with it's extension is actually safe so there could be additional code changes to Kodi needed (in order to make the module multi-init safe). You could just try it and see if anything breaks.
The modern way to create Python extensions is with m_size >= 0. The -1 (legacy single-phase init style) is the deprecated way. It should still work to do things that way and if it doesn't it's a bug in Python.
If you want to avoid the bugs with a Kodi source change, it's possible you can change the "-1" on the line following "static struct PyModuleDef createModule " to be "0" instead.
If a grep for 'static struct PyModuleDef createModule' in the kodi source tree, I found it in xbmc/interfaces/python/PythonSwig.cpp.template
You're saying change line 887 to 0 and then build kodi, yes? Should I test that modification with my modified python-3.12.6 (including the two PRs you linked above) or should I test with the Arch repo package for python-3.12.6?
I'm not familiar with the Kodi source code but that looks like the correct and only place that needs a change. Re-building and testing with a Python without the two fixes (e.g. with 3.16.6) would be useful to see if that change avoids the crash bug (should be triggered when the embedded Python interpreter shutdowns).
Deciding if that's a safe change to make is a bit harder. If it runs okay (and you can use Python modules/extensions) then it might be okay. The best would be to review the Kodi extension module source code but that would take someone familiar with Python extensions and also with Kodi.