daphne-eu / daphne

DAPHNE: An Open and Extensible System Infrastructure for Integrated Data Analysis Pipelines
Apache License 2.0
67 stars 62 forks source link

Help! Seg fault when running any DaphneLib code #816

Closed divjakm closed 2 months ago

divjakm commented 2 months ago

I wanted to try combining Python with DaphneLib but it seems I'm doing something wrong and I can't figure out what.

My OS is Kubuntu 24.04, installed in a QEMU/KVM virtual machine. I cloned the latest version of Daphne source code from GitHub and built it using the build.sh script. Then I followed the instructions for using DaphneLib (https://daphne-eu.github.io/daphne/DaphneLib/Overview/):

At first I didn't install the Daphne Python package, I followed the instructions in the section "Use Without Installation". So I set the PYTHONPATH and I modified the run_python.sh to use the python3 executable from my Anaconda installation. If I try running the simplest provided DaphneLib example with: ./run_python.sh scripts/examples/daphnelib/shift-and-scale.py I get an error message and a segmentation fault:

divjak@DaphneVM:~/Work/daphne$ ./run-python.sh scripts/examples/daphnelib/shift-and-scale.py 
terminate called after throwing an instance of 'std::runtime_error'
  what():  error while parsing kernel catalog file `/home/divjak/Work/daphne/lib/catalog.json`: KernelCatalogParser: error while parsing argument types of kernel `_print__List_DenseMatrix_double__bool__bool` for operation `print` (backend `CPP`): unknown type for argument #0: `List<DenseMatrix<double>>`
/home/divjak/Work/daphne/lib/libdaphnelib.so(_Z13handleSignalsi+0x32)[0x717ebb8fad32]
/lib/x86_64-linux-gnu/libc.so.6(+0x45320)[0x717ebfc45320]
/lib/x86_64-linux-gnu/libc.so.6(pthread_kill+0x11c)[0x717ebfc9eb1c]
/lib/x86_64-linux-gnu/libc.so.6(gsignal+0x1e)[0x717ebfc4526e]
/lib/x86_64-linux-gnu/libc.so.6(abort+0xdf)[0x717ebfc288ff]
/lib/x86_64-linux-gnu/libstdc++.so.6(+0xa5ffe)[0x717eb94a5ffe]
/lib/x86_64-linux-gnu/libstdc++.so.6(+0xbae9c)[0x717eb94bae9c]
/lib/x86_64-linux-gnu/libstdc++.so.6(_ZSt10unexpectedv+0x0)[0x717eb94a5a49]
/lib/x86_64-linux-gnu/libstdc++.so.6(+0xbb128)[0x717eb94bb128]
/home/divjak/Work/daphne/lib/libdaphnelib.so(+0x24175eb)[0x717ebbc175eb]
/home/divjak/Work/daphne/lib/libdaphnelib.so(_Z11startDAPHNEiPPKcP15DaphneLibResultPiR16DaphneUserConfig+0xb4a)[0x717ebb92bada]
/home/divjak/Work/daphne/lib/libdaphnelib.so(_Z12mainInternaliPPKcP15DaphneLibResult+0x1b7)[0x717ebb9310a7]
/home/divjak/Work/daphne/lib/libdaphnelib.so(daphne+0x54)[0x717ebb8f9944]
/home/divjak/anaconda3/lib/python3.12/lib-dynload/../../libffi.so.8(+0xa052)[0x717ebfe68052]
/home/divjak/anaconda3/lib/python3.12/lib-dynload/../../libffi.so.8(+0x8925)[0x717ebfe66925]
/home/divjak/anaconda3/lib/python3.12/lib-dynload/../../libffi.so.8(ffi_call+0xde)[0x717ebfe6706e]
/home/divjak/anaconda3/lib/python3.12/lib-dynload/_ctypes.cpython-312-x86_64-linux-gnu.so(+0x97b7)[0x717ebfe787b7]
/home/divjak/anaconda3/lib/python3.12/lib-dynload/_ctypes.cpython-312-x86_64-linux-gnu.so(+0x8bd5)[0x717ebfe77bd5]
/home/divjak/anaconda3/bin/python3(_PyObject_MakeTpCall+0x2fb)[0x51b30b]
/home/divjak/anaconda3/bin/python3(_PyEval_EvalFrameDefault+0x6d5)[0x525e75]
/home/divjak/anaconda3/bin/python3(PyEval_EvalCode+0xae)[0x5e4dfe]
/home/divjak/anaconda3/bin/python3[0x60a5d7]
/home/divjak/anaconda3/bin/python3[0x605ca7]
/home/divjak/anaconda3/bin/python3[0x61db12]
/home/divjak/anaconda3/bin/python3(_PyRun_SimpleFileObject+0x1b0)[0x61d3b0]
./run-python.sh: line 26: 12537 Segmentation fault      (core dumped) /home/divjak/anaconda3/bin/python3 $@

Then I tried installing the Daphne Python package into a pip virtual environment. The installation was successfull, but when I try to run the example code I get the same error:

(test_venv) divjak@DaphneVM:~/Work/daphne$ python3 scripts/examples/daphnelib/shift-and-scale.py
terminate called after throwing an instance of 'std::runtime_error'
  what():  error while parsing kernel catalog file `/home/divjak/Work/daphne/lib/catalog.json`: KernelCatalogParser: error while parsing argument types of kernel `_print__List_DenseMatrix_double__bool__bool` for operation `print` (backend `CPP`): unknown type for argument #0: `List<DenseMatrix<double>>`
/home/divjak/Work/daphne/lib/libdaphnelib.so(_Z13handleSignalsi+0x32)[0x783202cfad32]
/lib/x86_64-linux-gnu/libc.so.6(+0x45320)[0x783207045320]
/lib/x86_64-linux-gnu/libc.so.6(pthread_kill+0x11c)[0x78320709eb1c]
/lib/x86_64-linux-gnu/libc.so.6(gsignal+0x1e)[0x78320704526e]
/lib/x86_64-linux-gnu/libc.so.6(abort+0xdf)[0x7832070288ff]
/lib/x86_64-linux-gnu/libstdc++.so.6(+0xa5ffe)[0x7832008a5ffe]
/lib/x86_64-linux-gnu/libstdc++.so.6(+0xbae9c)[0x7832008bae9c]
/lib/x86_64-linux-gnu/libstdc++.so.6(_ZSt10unexpectedv+0x0)[0x7832008a5a49]
/lib/x86_64-linux-gnu/libstdc++.so.6(+0xbb128)[0x7832008bb128]
/home/divjak/Work/daphne/lib/libdaphnelib.so(+0x24175eb)[0x7832030175eb]
/home/divjak/Work/daphne/lib/libdaphnelib.so(_Z11startDAPHNEiPPKcP15DaphneLibResultPiR16DaphneUserConfig+0xb4a)[0x783202d2bada]
/home/divjak/Work/daphne/lib/libdaphnelib.so(_Z12mainInternaliPPKcP15DaphneLibResult+0x1b7)[0x783202d310a7]
/home/divjak/Work/daphne/lib/libdaphnelib.so(daphne+0x54)[0x783202cf9944]
/home/divjak/anaconda3/lib/python3.12/lib-dynload/../../libffi.so.8(+0xa052)[0x78320725a052]
/home/divjak/anaconda3/lib/python3.12/lib-dynload/../../libffi.so.8(+0x8925)[0x783207258925]
/home/divjak/anaconda3/lib/python3.12/lib-dynload/../../libffi.so.8(ffi_call+0xde)[0x78320725906e]
/home/divjak/anaconda3/lib/python3.12/lib-dynload/_ctypes.cpython-312-x86_64-linux-gnu.so(+0x97b7)[0x78320726a7b7]
/home/divjak/anaconda3/lib/python3.12/lib-dynload/_ctypes.cpython-312-x86_64-linux-gnu.so(+0x8bd5)[0x783207269bd5]
python3(_PyObject_MakeTpCall+0x75)[0x548d15]
python3(_PyEval_EvalFrameDefault+0xa89)[0x5d70f9]
python3(PyEval_EvalCode+0x15b)[0x5d560b]
python3[0x608812]
python3[0x6b50e3]
python3(_PyRun_SimpleFileObject+0x1aa)[0x6b4e4a]
python3(_PyRun_AnyFileObject+0x4f)[0x6b4c7f]
Segmentation fault (core dumped)
(test_venv) divjak@DaphneVM:~/Work/daphne$ 

Does anybody have any idea what I'm doing wrong?

pdamme commented 2 months ago

Hi @divjakm, thanks for reporting this issue. I suspect that your compiled instance of DaphneLib (lib/libdaphnelib.so) is outdated. Please try to rebuild DaphneLib by doing ./build.sh --target daphnelib and then try executing the shift-and-scale.py script again. That might already solve your problem.


For some background:

Further action for the DAPHNE development:

divjakm commented 2 months ago

Thank you! Re-compilation solved the problem. I forgot to try that before because I already had the *.so files in the /lib folder after the default building process and I thought it's not necessary to explicitly build DaphneLib. It works now!