koordinates/kart

subprocess.CalledProcessError: Command '['pdal', '--version']' died with <Signals.SIGSEGV: 11>

Closed this issue · 2 comments

Describe the bug
Running "kart --version" results in a segfault on Fedora 37, with the output:

Kart v0.12.2, Copyright (c) Kart Contributors
kart helper: unhandled exception
Traceback (most recent call last):
  File "kart/helper.py", line 236, in helper
  File "click/core.py", line 1130, in __call__
  File "click/core.py", line 1054, in main
  File "click/core.py", line 920, in make_context
  File "click/core.py", line 1613, in parse_args
  File "click/core.py", line 1378, in parse_args
  File "click/core.py", line 2360, in handle_parse_result
  File "click/core.py", line 2322, in process_value
  File "kart/cli_util.py", line 403, in actual_callback
  File "kart/cli.py", line 115, in print_version
  File "subprocess.py", line 420, in check_output
  File "subprocess.py", line 524, in run
subprocess.CalledProcessError: Command '['pdal', '--version']' died with <Signals.SIGSEGV: 11>.

(For reference, pdal --version doesn't crash -- it outputs:

-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
pdal 2.4.3 (git-version: Release)
-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
```)


This breaks the QGIS plugin, as it intreprets the segfault as a missing kart executable
 
**To Reproduce**
Steps to reproduce the behaviour:
1. Install kart on fedora 37
2. Run "kart --version"

rcoup commented

mmm, works for me under arm64:

$ docker run --rm -it -v $(pwd):/mnt fedora:37
[root@907b2c2dd5d4 /]# yum install -y /mnt/kart-0.12.2-1.aarch64.rpm
...
[root@907b2c2dd5d4 /]# kart --version
Kart v0.12.2, Copyright (c) Kart Contributors
» GDAL v3.6.2; PROJ v9.1.1; PDAL v2.4.3
» PyGit2 v1.9.0; Libgit2 v1.4.2; Git v2.38.1; Git LFS v3.3.0
» SQLAlchemy v1.4.45; pysqlite3 v2.6.0/v3.40.0; SpatiaLite v5.0.1; Libpq v14.0.4
Executed via helper, PID: 85

I did get a similar error under amd64 though:

$ docker run --rm -it --platform=linux/amd64 -v $(pwd):/mnt fedora:37
[root@192dd063833d /]# yum install -y /mnt/kart-0.12.2-1.x86_64.rpm
...
[root@192dd063833d /]# kart --version
Kart v0.12.2, Copyright (c) Kart Contributors
kart helper: unhandled exception
Traceback (most recent call last):
  File "kart/helper.py", line 236, in helper
  File "click/core.py", line 1130, in __call__
  File "click/core.py", line 1054, in main
  File "click/core.py", line 920, in make_context
  File "click/core.py", line 1613, in parse_args
  File "click/core.py", line 1378, in parse_args
  File "click/core.py", line 2360, in handle_parse_result
  File "click/core.py", line 2322, in process_value
  File "kart/cli_util.py", line 403, in actual_callback
  File "kart/cli.py", line 101, in print_version
  File "subprocess.py", line 420, in check_output
  File "subprocess.py", line 524, in run
subprocess.CalledProcessError: Command '['git', '--version']' returned non-zero exit status 127.
[root@192dd063833d /]# /opt/kart/git --version
/opt/kart/git: error while loading shared libraries: libz.so: cannot open shared object file: No such file or directory
[root@192dd063833d /]# /opt/kart/pdal --version
/opt/kart/pdal: error while loading shared libraries: lib: cannot open shared object file: No such file or directory

Can you try with the rpm from the latest master build and see if that helps at all?

Otherwise, does /opt/kart/pdal --version work or return an error?

rcoup commented

(reproduces for me under amd64 with the latest master build too)

/opt/kart/git also shows a similar error, and has a smaller dependency tree:

[root@2bb827757d1d kart]# /opt/kart/git --version
/opt/kart/git: error while loading shared libraries: libz.so: cannot open shared object file: No such file or directory

ldd shows the expected libraries

[root@2bb827757d1d kart]# ldd /opt/kart/git
	libpcre2-8.so.0.11.0 => /opt/kart/libpcre2-8.so.0.11.0 (0x00007ffffff24000)
	libz.so.1.2.13 => /opt/kart/libz.so.1.2.13 (0x00007ffffff04000)
	libpthread.so.0 => /lib64/libpthread.so.0 (0x00007fffffefc000)
	librt.so.1 => /lib64/librt.so.1 (0x00007fffffef7000)
	libsqlite3.so => /opt/kart/libsqlite3.so (0x00007fffffdb6000)
	libstdc++.so.6 => /lib64/libstdc++.so.6 (0x00007fffffb82000)
	libm.so.6 => /lib64/libm.so.6 (0x00007fffffaa0000)
	libgcc_s.so.1 => /lib64/libgcc_s.so.1 (0x00007fffffa80000)
	libc.so.6 => /lib64/libc.so.6 (0x00007fffff8a3000)
	libdl.so.2 => /lib64/libdl.so.2 (0x00007fffff89e000)
	/lib64/ld-linux-x86-64.so.2 (0x00007ffffffc9000)

but LD_DEBUG=all shows

[root@2bb827757d1d kart]# LD_DEBUG=all /opt/kart/git --version
       204:
       204:	file=libpcre2-8.so.0.11.0 [0];  needed by /opt/kart/git [0]
       204:	find library=libpcre2-8.so.0.11.0 [0]; searching
       204:	 search path=/opt/kart/glibc-hwcaps/x86-64-v2:/opt/kart/tls/x86_64/x86_64:/opt/kart/tls/x86_64:/opt/kart/tls/x86_64:/opt/kart/tls:/opt/kart/x86_64/x86_64:/opt/kart/x86_64:/opt/kart/x86_64:/opt/kart:/opt/kart/../lib/glibc-hwcaps/x86-64-v2:/opt/kart/../lib/tls/x86_64/x86_64:/opt/kart/../lib/tls/x86_64:/opt/kart/../lib/tls/x86_64:/opt/kart/../lib/tls:/opt/kart/../lib/x86_64/x86_64:/opt/kart/../lib/x86_64:/opt/kart/../lib/x86_64:/opt/kart/../lib		(RUNPATH from file /opt/kart/git)
       204:	  trying file=/opt/kart/glibc-hwcaps/x86-64-v2/libpcre2-8.so.0.11.0
       204:	  trying file=/opt/kart/tls/x86_64/x86_64/libpcre2-8.so.0.11.0
       204:	  trying file=/opt/kart/tls/x86_64/libpcre2-8.so.0.11.0
       204:	  trying file=/opt/kart/tls/x86_64/libpcre2-8.so.0.11.0
       204:	  trying file=/opt/kart/tls/libpcre2-8.so.0.11.0
       204:	  trying file=/opt/kart/x86_64/x86_64/libpcre2-8.so.0.11.0
       204:	  trying file=/opt/kart/x86_64/libpcre2-8.so.0.11.0
       204:	  trying file=/opt/kart/x86_64/libpcre2-8.so.0.11.0
       204:	  trying file=/opt/kart/libpcre2-8.so.0.11.0
       204:
       204:	file=libpcre2-8.so.0.11.0 [0];  generating link map
       204:	  dynamic: 0x00007ffffffc5150  base: 0x00007ffffff24000   size: 0x00000000000a2d38
       204:	    entry: 0x00007ffffff273b0  phdr: 0x00007ffffff24040  phnum:                 11
       204:
       204:
       204:	file=libz.so [0];  needed by /opt/kart/git [0]
       204:	find library=libz.so [0]; searching
       204:	 search path=/opt/kart:/opt/kart/../lib/glibc-hwcaps/x86-64-v2:/opt/kart/../lib/tls/x86_64/x86_64:/opt/kart/../lib/tls/x86_64:/opt/kart/../lib/tls/x86_64:/opt/kart/../lib/tls:/opt/kart/../lib/x86_64/x86_64:/opt/kart/../lib/x86_64:/opt/kart/../lib/x86_64:/opt/kart/../lib		(RUNPATH from file /opt/kart/git)
       204:	  trying file=/opt/kart/libz.so
       204:	  trying file=/opt/kart/../lib/glibc-hwcaps/x86-64-v2/libz.so
       204:	  trying file=/opt/kart/../lib/tls/x86_64/x86_64/libz.so
       204:	  trying file=/opt/kart/../lib/tls/x86_64/libz.so
       204:	  trying file=/opt/kart/../lib/tls/x86_64/libz.so
       204:	  trying file=/opt/kart/../lib/tls/libz.so
       204:	  trying file=/opt/kart/../lib/x86_64/x86_64/libz.so
       204:	  trying file=/opt/kart/../lib/x86_64/libz.so
       204:	  trying file=/opt/kart/../lib/x86_64/libz.so
       204:	  trying file=/opt/kart/../lib/libz.so
       204:	 search cache=/etc/ld.so.cache
       204:	 search path=/lib64/glibc-hwcaps/x86-64-v2:/lib64/tls/x86_64/x86_64:/lib64/tls/x86_64:/lib64/tls/x86_64:/lib64/tls:/lib64/x86_64/x86_64:/lib64/x86_64:/lib64/x86_64:/lib64:/usr/lib64/glibc-hwcaps/x86-64-v2:/usr/lib64/tls/x86_64/x86_64:/usr/lib64/tls/x86_64:/usr/lib64/tls/x86_64:/usr/lib64/tls:/usr/lib64/x86_64/x86_64:/usr/lib64/x86_64:/usr/lib64/x86_64:/usr/lib64		(system search path)
       204:	  trying file=/lib64/glibc-hwcaps/x86-64-v2/libz.so
       204:	  trying file=/lib64/tls/x86_64/x86_64/libz.so
       204:	  trying file=/lib64/tls/x86_64/libz.so
       204:	  trying file=/lib64/tls/x86_64/libz.so
       204:	  trying file=/lib64/tls/libz.so
       204:	  trying file=/lib64/x86_64/x86_64/libz.so
       204:	  trying file=/lib64/x86_64/libz.so
       204:	  trying file=/lib64/x86_64/libz.so
       204:	  trying file=/lib64/libz.so
       204:	  trying file=/usr/lib64/glibc-hwcaps/x86-64-v2/libz.so
       204:	  trying file=/usr/lib64/tls/x86_64/x86_64/libz.so
       204:	  trying file=/usr/lib64/tls/x86_64/libz.so
       204:	  trying file=/usr/lib64/tls/x86_64/libz.so
       204:	  trying file=/usr/lib64/tls/libz.so
       204:	  trying file=/usr/lib64/x86_64/x86_64/libz.so
       204:	  trying file=/usr/lib64/x86_64/libz.so
       204:	  trying file=/usr/lib64/x86_64/libz.so
       204:	  trying file=/usr/lib64/libz.so
       204:
/opt/kart/git: error while loading shared libraries: libz.so: cannot open shared object file: No such file or directory

So, it's searching for libz.so even though both readelf & objdump show it depending on libz.so.1.2.13 (which exists):

[root@2bb827757d1d kart]# readelf -d /opt/kart/git | grep NEEDED
 0x0000000000000001 (NEEDED)             Shared library: [libpcre2-8.so.0.11.0]
 0x0000000000000001 (NEEDED)             Shared library: [libz.so.1.2.13]
 0x0000000000000001 (NEEDED)             Shared library: [libpthread.so.0]
 0x0000000000000001 (NEEDED)             Shared library: [librt.so.1]
 0x0000000000000001 (NEEDED)             Shared library: [libsqlite3.so]
 0x0000000000000001 (NEEDED)             Shared library: [libstdc++.so.6]
 0x0000000000000001 (NEEDED)             Shared library: [libm.so.6]
 0x0000000000000001 (NEEDED)             Shared library: [libgcc_s.so.1]
 0x0000000000000001 (NEEDED)             Shared library: [libc.so.6]
[root@2bb827757d1d kart]# objdump -x /opt/kart/git | grep NEEDED
  NEEDED               libpcre2-8.so.0.11.0
  NEEDED               libz.so.1.2.13
  NEEDED               libpthread.so.0
  NEEDED               librt.so.1
  NEEDED               libsqlite3.so
  NEEDED               libstdc++.so.6
  NEEDED               libm.so.6
  NEEDED               libgcc_s.so.1
  NEEDED               libc.so.6

mmm... I think this might be our ongoing battle with patchelf edge cases when rewriting rpaths...

[root@2bb827757d1d kart]# eu-elflint /opt/kart/git
section [ 6] '.dynstr' not fully contained in segment of program header entry 2
loadable segment [2] is writable but contains no writable sections

NixOS/patchelf#482 seems similar, and has a fix in NixOS/patchelf#485

Will try and see if that fixes it.