Message ID | 20200910125731.3415057-1-jo@mein.io |
---|---|
State | Accepted |
Delegated to: | Jo-Philipp Wich |
Headers | show |
Series | [1/2] fakeroot: make fakeroot script relocatable | expand |
Jo-Philipp Wich <jo@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@entry=0x7fcea85df435 "__vdso_time", new_hash=new_hash@entry=2183040525, old_hash=old_hash@entry=0x7ffce43e3180, ref=0x7ffce43e3230, result=result@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@entry=0x7fcea85df435 "__vdso_time", new_hash=new_hash@entry=2183040525, old_hash=old_hash@entry=0x7ffce43e3180, ref=0x7ffce43e3230, result=result@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@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@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"
Hi, > 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. Yes, that is why we wrap the SDK executables to forcibly invoke them through the bundled loader. Attempting to use SDK executables or librries with the host system LDSO will result in undefined behavior. I probably missed the point of your mail - do you meant to imply that my patch introduced this regression? ~ Jo
On Mon Nov 9, 2020 at 7:33 AM HST, Jo-Philipp Wich wrote: > I probably missed the point of your mail - do you meant to imply that my > patch introduced this regression? Since the CI builds start failing the same day as the patches were commited there could be a correlation. There is also a GitHub issue open: https://github.com/openwrt/packages/issues/13855 Sunshine, Paul
Paul Spooren <mail@aparcar.org> [2020-11-09 08:58:16]: > On Mon Nov 9, 2020 at 7:33 AM HST, Jo-Philipp Wich wrote: > > I probably missed the point of your mail - do you meant to imply that my > > patch introduced this regression? > > Since the CI builds start failing the same day as the patches were > commited there could be a correlation. There is also a GitHub issue > open: https://github.com/openwrt/packages/issues/13855 For the archives, it was fixed by Jo in https://git.openwrt.org/d4521fb132266 -- ynezz
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@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"
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. Signed-off-by: Jo-Philipp Wich <jo@mein.io> --- tools/fakeroot/patches/000-relocatable.patch | 25 ++++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 tools/fakeroot/patches/000-relocatable.patch