python-zstandard icon indicating copy to clipboard operation
python-zstandard copied to clipboard

SIGSEGV in ZSTD_freeDDict()

Open pva opened this issue 1 year ago • 2 comments

Hi, I'm not sure that bug is in zstandard, but probably you could point me where to look next. After I've rebuilt my system with gcc-14/llvm-18 anki started to crash. Backtrace is the following:

Thread 1 "python3.10" received signal SIGSEGV, Segmentation fault.
0x00007ffff41606c0 in ZSTD_freeDDict ()
   from /usr/lib/python3.10/site-packages/zstandard/_cffi.cpython-310-x86_64-linux-gnu.so
(gdb) bt
#0  0x00007ffff41606c0 in ZSTD_freeDDict ()
    at /usr/lib/python3.10/site-packages/zstandard/_cffi.cpython-310-x86_64-linux-gnu.so
#1  0x00007ffff4166bbb in ZSTD_decompressDCtx ()
    at /usr/lib/python3.10/site-packages/zstandard/_cffi.cpython-310-x86_64-linux-gnu.so
#2  0x00007ffff404513b in ZSTD_decompress () at /usr/lib64/libzstd.so.1
#3  0x00007ffff32f1af2 in QResourcePrivate::decompress(char*, long long) const () at /usr/lib64/libQt6Core.so.6
#4  0x00007ffff3308f62 in QResource::uncompressedData() const () at /usr/lib64/libQt6Core.so.6
#5  0x00007ffff3309038 in QResourceFileEnginePrivate::uncompress() const () at /usr/lib64/libQt6Core.so.6
#6  0x00007ffff33090fc in QResourceFileEngine::open(QFlags<QIODeviceBase::OpenModeFlag>, std::optional<QFlags<QFileDevice::Permission> >) () at /usr/lib64/libQt6Core.so.6
#7  0x00007ffff3341eb0 in QFile::open(QFlags<QIODeviceBase::OpenModeFlag>) () at /usr/lib64/libQt6Core.so.6
#8  0x00007ffff374fc75 in meth_QFile_open () at /usr/lib/python3.10/site-packages/PyQt6/QtCore.abi3.so
#9  0x00007ffff7cfca7d in cfunction_call () at /usr/lib64/libpython3.10.so.1.0
#10 0x00007ffff7cdb8f3 in _PyObject_MakeTpCall () at /usr/lib64/libpython3.10.so.1.0
#11 0x00007ffff7d37374 in _PyEval_EvalFrameDefault () at /usr/lib64/libpython3.10.so.1.0
#12 0x00007ffff7d30250 in _PyEval_Vector () at /usr/lib64/libpython3.10.so.1.0
#13 0x00007ffff7cdd03f in method_vectorcall () at /usr/lib64/libpython3.10.so.1.0
#14 0x00007ffff7d32420 in _PyEval_EvalFrameDefault () at /usr/lib64/libpython3.10.so.1.0
#15 0x00007ffff7d30250 in _PyEval_Vector () at /usr/lib64/libpython3.10.so.1.0
#16 0x00007ffff7cdb77f in _PyObject_FastCallDictTstate () at /usr/lib64/libpython3.10.so.1.0
#17 0x00007ffff7cdc239 in _PyObject_Call_Prepend () at /usr/lib64/libpython3.10.so.1.0
#18 0x00007ffff7d0ce2c in slot_tp_init () at /usr/lib64/libpython3.10.so.1.0
#19 0x00007ffff7d0a6bf in type_call () at /usr/lib64/libpython3.10.so.1.0
#20 0x00007ffff7cdb8f3 in _PyObject_MakeTpCall () at /usr/lib64/libpython3.10.so.1.0
#21 0x00007ffff7d3354f in _PyEval_EvalFrameDefault () at /usr/lib64/libpython3.10.so.1.0
#22 0x00007ffff7d30250 in _PyEval_Vector () at /usr/lib64/libpython3.10.so.1.0
#23 0x00007ffff7d330c3 in _PyEval_EvalFrameDefault () at /usr/lib64/libpython3.10.so.1.0
#24 0x00007ffff7d30250 in _PyEval_Vector () at /usr/lib64/libpython3.10.so.1.0
#25 0x00007ffff7cdd03f in method_vectorcall () at /usr/lib64/libpython3.10.so.1.0
#26 0x00007ffff7d330c3 in _PyEval_EvalFrameDefault () at /usr/lib64/libpython3.10.so.1.0
#27 0x00007ffff7d30250 in _PyEval_Vector () at /usr/lib64/libpython3.10.so.1.0
#28 0x00007ffff7cdb77f in _PyObject_FastCallDictTstate () at /usr/lib64/libpython3.10.so.1.0
#29 0x00007ffff7cdc239 in _PyObject_Call_Prepend () at /usr/lib64/libpython3.10.so.1.0
#30 0x00007ffff7d0ce2c in slot_tp_init () at /usr/lib64/libpython3.10.so.1.0
#31 0x00007ffff7d0a6bf in type_call () at /usr/lib64/libpython3.10.so.1.0
#32 0x00007ffff7cdb8f3 in _PyObject_MakeTpCall () at /usr/lib64/libpython3.10.so.1.0
#33 0x00007ffff7d3354f in _PyEval_EvalFrameDefault () at /usr/lib64/libpython3.10.so.1.0
#34 0x00007ffff7d30250 in _PyEval_Vector () at /usr/lib64/libpython3.10.so.1.0
#35 0x00007ffff7cdd03f in method_vectorcall () at /usr/lib64/libpython3.10.so.1.0
#36 0x00007ffff7d32420 in _PyEval_EvalFrameDefault () at /usr/lib64/libpython3.10.so.1.0
#37 0x00007ffff7d30250 in _PyEval_Vector () at /usr/lib64/libpython3.10.so.1.0
#38 0x00007ffff7cdd03f in method_vectorcall () at /usr/lib64/libpython3.10.so.1.0
#39 0x00007ffff7d32420 in _PyEval_EvalFrameDefault () at /usr/lib64/libpython3.10.so.1.0
#40 0x00007ffff7d30250 in _PyEval_Vector () at /usr/lib64/libpython3.10.so.1.0
#41 0x00007ffff7cdb77f in _PyObject_FastCallDictTstate () at /usr/lib64/libpython3.10.so.1.0
#42 0x00007ffff7cdc2b7 in _PyObject_Call_Prepend () at /usr/lib64/libpython3.10.so.1.0
#43 0x00007ffff7d0ce2c in slot_tp_init () at /usr/lib64/libpython3.10.so.1.0
#44 0x00007ffff7d0a6bf in type_call () at /usr/lib64/libpython3.10.so.1.0
#45 0x00007ffff7cdb8f3 in _PyObject_MakeTpCall () at /usr/lib64/libpython3.10.so.1.0
#46 0x00007ffff7d37374 in _PyEval_EvalFrameDefault () at /usr/lib64/libpython3.10.so.1.0
#47 0x00007ffff7d30250 in _PyEval_Vector () at /usr/lib64/libpython3.10.so.1.0
#48 0x00007ffff7d317a3 in _PyEval_EvalFrameDefault () at /usr/lib64/libpython3.10.so.1.0
#49 0x00007ffff7d30250 in _PyEval_Vector () at /usr/lib64/libpython3.10.so.1.0
#50 0x00007ffff7d317a3 in _PyEval_EvalFrameDefault () at /usr/lib64/libpython3.10.so.1.0
#51 0x00007ffff7d30250 in _PyEval_Vector () at /usr/lib64/libpython3.10.so.1.0
#52 0x00007ffff7d301db in PyEval_EvalCode () at /usr/lib64/libpython3.10.so.1.0
#53 0x00007ffff7dc1ab3 in run_eval_code_obj () at /usr/lib64/libpython3.10.so.1.0
#54 0x00007ffff7dc1a4a in run_mod () at /usr/lib64/libpython3.10.so.1.0
#55 0x00007ffff7dc19bd in PyRun_StringFlags () at /usr/lib64/libpython3.10.so.1.0
#56 0x00007ffff7d2e489 in builtin_exec () at /usr/lib64/libpython3.10.so.1.0
#57 0x00007ffff7cfcb23 in cfunction_vectorcall_FASTCALL () at /usr/lib64/libpython3.10.so.1.0
#58 0x00007ffff7d317a3 in _PyEval_EvalFrameDefault () at /usr/lib64/libpython3.10.so.1.0
#59 0x00007ffff7d30250 in _PyEval_Vector () at /usr/lib64/libpython3.10.so.1.0
#60 0x00007ffff7d301db in PyEval_EvalCode () at /usr/lib64/libpython3.10.so.1.0
#61 0x00007ffff7dc1ab3 in run_eval_code_obj () at /usr/lib64/libpython3.10.so.1.0
#62 0x00007ffff7dc1a4a in run_mod () at /usr/lib64/libpython3.10.so.1.0
#63 0x00007ffff7dc297f in pyrun_file () at /usr/lib64/libpython3.10.so.1.0
#64 0x00007ffff7dc2772 in _PyRun_SimpleFileObject () at /usr/lib64/libpython3.10.so.1.0
#65 0x00007ffff7dc25a4 in _PyRun_AnyFileObject () at /usr/lib64/libpython3.10.so.1.0
#66 0x00007ffff7dca1a2 in Py_RunMain () at /usr/lib64/libpython3.10.so.1.0
#67 0x00007ffff7dc9c77 in Py_BytesMain () at /usr/lib64/libpython3.10.so.1.0
#68 0x00007ffff7a47f4e in __libc_start_call_main () at /lib64/libc.so.6
#69 0x00007ffff7a48009 in __libc_start_main () at /lib64/libc.so.6
#70 0x0000555555555085 in _start ()
(gdb) 

anki is a python application, that uses dev-python/PyQt6. I'll plan to read the code to understand what's going on, but does this look correct that ZSTD_decompress () from zstd (/usr/lib64/libzstd.so.1) uses ZSTD_decompressDCtx() from zstandard python bindings?

I'm using zstandard 0.22.0 with all the fixes from the current master and zstd 1.5.6.

Thanks in advance for any hints.

pva avatar Jun 25 '24 10:06 pva

Ok, it looks like this is our platform issue. I've noticed the following code in zstandard-0.22.0.ebuild:

    # the C backend is repeatedly broken, so force CFFI instead
    sed -e '/PYTHON_ZSTANDARD_IMPORT_POLICY/s:default:cffi:' \
        -i zstandard/__init__.py || die

Once I switch to PYTHON_ZSTANDARD_IMPORT_POLICY="CPython" anki starts to work. So, my suspicion that this is somehow related to linkage is correct. Now I need to understand what's broken with cffi.

pva avatar Jul 02 '24 10:07 pva

Reported issue here: https://bugs.gentoo.org/935342

pva avatar Jul 02 '24 10:07 pva

It appears this was an issue with gentoo's build of this package and how the zstd library was loaded. So closing.

indygreg avatar Aug 17 '25 16:08 indygreg