x86/64 SDK segfaults on some hosts [Was: Re: [PATCH 1/2] fakeroot: make fakeroot script relocatable]
Petr Štetiar
ynezz at true.cz
Mon Nov 9 11:45:27 EST 2020
Jo-Philipp Wich <jo at mein.io> [2020-09-10 14:57:30]:
Hi,
> Patch the fakeroot script template to discover faked and libfakeroot.so
> relative to the STAGING_DIR_HOST environment variable, similar to how it
> is done for automake, libtool, quilt and autoconf already.
>
> This avoids the need for passing the paths to faked and libfakeroot.so
> manually every time we invoke fakeroot and subsequently allows us to
> drop OS X specific logic.
it seems like mixing dynamic loader from the host and libraries from SDK
doesn't work reliably in all cases and may result in crash.
Using loader from SDK works:
$ /sdk/staging_dir/host/lib/ld-linux-x86-64.so.2 --library-path /sdk/staging_dir/host/lib /bin/uname
Linux
Using loader from host doesn't work and crashes:
$ /lib64/ld-linux-x86-64.so.2 --library-path /sdk/staging_dir/host/lib /bin/uname
Segmentation fault (core dumped)
With gdb it's visible, that there seems to be issue with __vdso_time from linux-vdso.so.1:
Starting program: /lib64/ld-linux-x86-64.so.2 --library-path /sdk/staging_dir/host/lib /bin/uname
Program received signal SIGSEGV, Segmentation fault.
0x00007fcea8831881 in do_lookup_x (undef_name=undef_name at entry=0x7fcea85df435 "__vdso_time", new_hash=new_hash at entry=2183040525, old_hash=old_hash at entry=0x7ffce43e3180, ref=0x7ffce43e3230,
result=result at entry=0x7ffce43e3190, scope=<optimized out>, i=1, version=0x7ffce43e3260, flags=0, skip=0x0, type_class=0, undef_map=0x7fcea8851760) at dl-lookup.c:350
350 dl-lookup.c: No such file or directory.
(gdb) bt
#0 0x00007fcea8831881 in do_lookup_x (undef_name=undef_name at entry=0x7fcea85df435 "__vdso_time", new_hash=new_hash at entry=2183040525, old_hash=old_hash at entry=0x7ffce43e3180, ref=0x7ffce43e3230,
result=result at entry=0x7ffce43e3190, scope=<optimized out>, i=1, version=0x7ffce43e3260, flags=0, skip=0x0, type_class=0, undef_map=0x7fcea8851760) at dl-lookup.c:350
#1 0x00007fcea883238f in _dl_lookup_symbol_x (undef_name=0x7fcea85df435 "__vdso_time", undef_map=0x7fcea8851760, ref=0x7ffce43e3228, symbol_scope=0x7fcea8851ae8, version=0x7ffce43e3260, type_class=0, flags=0,
skip_map=<optimized out>) at dl-lookup.c:814
#2 0x00007fcea8591654 in ?? ()
#3 0x0000000000000000 in ?? ()
Reproducer:
wget https://downloads.openwrt.org/snapshots/targets/x86/64/openwrt-sdk-x86-64_gcc-8.4.0_musl.Linux-x86_64.tar.xz ; \
tar xvf openwrt-sdk-x86-64_gcc-8.4.0_musl.Linux-x86_64.tar.xz -C /tmp ; \
docker run --rm -it \
-v /tmp/openwrt-sdk-x86-64_gcc-8.4.0_musl.Linux-x86_64:/sdk "debian:10" \
/bin/sh -c 'LD_LIBRARY_PATH=/sdk/staging_dir/host/lib uname'
BTW it seems to work inside debian:9 container.
It was discovered by the Docker SDK image testing[1].
1. https://gitlab.com/openwrt/docker/-/jobs/837338425#L229
Cheers,
Petr
> Signed-off-by: Jo-Philipp Wich <jo at mein.io>
> ---
> tools/fakeroot/patches/000-relocatable.patch | 25 ++++++++++++++++++++
> 1 file changed, 25 insertions(+)
> create mode 100644 tools/fakeroot/patches/000-relocatable.patch
>
> diff --git a/tools/fakeroot/patches/000-relocatable.patch b/tools/fakeroot/patches/000-relocatable.patch
> new file mode 100644
> index 0000000000..9f6915bfe8
> --- /dev/null
> +++ b/tools/fakeroot/patches/000-relocatable.patch
> @@ -0,0 +1,25 @@
> +--- a/scripts/fakeroot.in
> ++++ b/scripts/fakeroot.in
> +@@ -30,12 +30,19 @@ fatal ()
> + }
> +
> + # strip /bin/fakeroot to find install prefix
> +-FAKEROOT_PREFIX=@prefix@
> +-FAKEROOT_BINDIR=@bindir@
> ++if [ -n "$STAGING_DIR_HOST" ]; then
> ++ FAKEROOT_PREFIX="${STAGING_DIR_HOST}"
> ++ FAKEROOT_BINDIR="${STAGING_DIR_HOST}/bin"
> ++ FAKEROOT_LIBDIR="${STAGING_DIR_HOST}/lib"
> ++else
> ++ FAKEROOT_PREFIX=@prefix@
> ++ FAKEROOT_BINDIR=@bindir@
> ++ FAKEROOT_LIBDIR=@libdir@
> ++fi
> +
> + USEABSLIBPATH=@LDPRELOADABS@
> + LIB=lib at fakeroot_transformed@@DLSUFFIX@
> +-PATHS=@libdir@:${FAKEROOT_PREFIX}/lib64/libfakeroot:${FAKEROOT_PREFIX}/lib32/libfakeroot
> ++PATHS=${FAKEROOT_LIBDIR}:${FAKEROOT_PREFIX}/lib64/libfakeroot:${FAKEROOT_PREFIX}/lib32/libfakeroot
> + FAKED=${FAKEROOT_BINDIR}/@faked_transformed@
> +
> + FAKED_MODE="unknown-is-root"
More information about the openwrt-devel
mailing list