Subject: Re: bug#32894: Exception in validate-runpath phase

From: [email-masked] (Ludovic Courtès)
Date: Tue, 02 Oct 2018 14:31:10 +0200

Hello Julien,

Julien Lepiller <[email-masked]> skribis:

> Then, running:
>
> (elf-dynamic-info (call-with-input-file "libjsoundalsa.debuginfo"
> (compose parse-elf get-bytevector-all)))
> $79 = #<<elf-dynamic-info> soname: #f needed: () rpath: () runpath: ()>
>
> (elf-dynamic-info (call-with-input-file "libjsound.debuginfo" (compose
> parse-elf get-bytevector-all)))
> $80 = #<<elf-dynamic-info> soname: #f needed: (1) rpath: () runpath: ()>
>
> (elf-dynamic-info (call-with-input-file "libawt_xawt.debuginfo"
> (compose parse-elf get-bytevector-all)))
> $81 = #<<elf-dynamic-info> soname: #f needed: (3659183287175258)
> rpath: () runpath: ()>

The reason we get numbers here (rather than strings) is because the
PT_DYNAMIC segment lacks a string table (DT_STRTAB), and thus there’s
nowhere the DT_NEEDED strings can be looked for, AIUI.

That gremlin.scm lets the number through comes from this bit:

           (if string-table-offset
               (pointer->string
                (bytevector->pointer (elf-bytes elf)
                                     (vma->offset
                                      elf
                                      (+ string-table-offset value))))
               value))

This is a questionable choice, but the crux of the problem is that these
ELF files appear to be corrupt or at least non-conventional.

Even BFD (from Binutils) fails to make sense of it:

--8<---------------cut here---------------start------------->8---
$ readelf -a /tmp/libawt_xawt.debuginfo | grep NEED
$ readelf -a /tmp/libawt_xawt.debuginfo | grep PATH
--8<---------------cut here---------------end--------------->8---

Compare with this (random example):

--8<---------------cut here---------------start------------->8---
$ readelf -a ~/.guix-profile/lib/libEGL.so.1 | grep NEED
  [ 6] .gnu.version_r    VERNEED          0000000000004718  00004718
 0x0000000000000001 (NEEDED)             Shared library: [libxcb-dri2.so.0]
 0x0000000000000001 (NEEDED)             Shared library: [libX11-xcb.so.1]
 0x0000000000000001 (NEEDED)             Shared library: [libX11.so.6]
 0x0000000000000001 (NEEDED)             Shared library: [libxcb-dri3.so.0]
 0x0000000000000001 (NEEDED)             Shared library: [libxcb-xfixes.so.0]
 0x0000000000000001 (NEEDED)             Shared library: [libxcb-present.so.0]
 0x0000000000000001 (NEEDED)             Shared library: [libxcb-sync.so.1]
 0x0000000000000001 (NEEDED)             Shared library: [libxcb.so.1]
 0x0000000000000001 (NEEDED)             Shared library: [libXau.so.6]
 0x0000000000000001 (NEEDED)             Shared library: [libXdmcp.so.6]
 0x0000000000000001 (NEEDED)             Shared library: [libbsd.so.0]
 0x0000000000000001 (NEEDED)             Shared library: [libxshmfence.so.1]
 0x0000000000000001 (NEEDED)             Shared library: [libwayland-client.so.0]
 0x0000000000000001 (NEEDED)             Shared library: [libgbm.so.1]
 0x0000000000000001 (NEEDED)             Shared library: [libz.so.1]
 0x0000000000000001 (NEEDED)             Shared library: [libwayland-server.so.0]
 0x0000000000000001 (NEEDED)             Shared library: [libffi.so.6]
 0x0000000000000001 (NEEDED)             Shared library: [librt.so.1]
 0x0000000000000001 (NEEDED)             Shared library: [libexpat.so.1]
 0x0000000000000001 (NEEDED)             Shared library: [libdl.so.2]
 0x0000000000000001 (NEEDED)             Shared library: [libdrm.so.2]
 0x0000000000000001 (NEEDED)             Shared library: [libm.so.6]
 0x0000000000000001 (NEEDED)             Shared library: [libglapi.so.0]
 0x0000000000000001 (NEEDED)             Shared library: [libpthread.so.0]
 0x0000000000000001 (NEEDED)             Shared library: [libgcc_s.so.1]
 0x0000000000000001 (NEEDED)             Shared library: [libc.so.6]
 0x000000006ffffffe (VERNEED)            0x4718
 0x000000006fffffff (VERNEEDNUM)         5
ludo@ribbon ~/src/guix$ readelf -a ~/.guix-profile/lib/libEGL.so.1 | grep PATH
 0x000000000000001d (RUNPATH)            Library runpath: [/gnu/store/xmdk5z05kqxpwgagxhlv375x3f82dxb3-libxcb-1.13/lib:/gnu/store/bid7hvpnm8nq04vm4dszywxsw9g2kmf2-libx11-1.6.6/lib:/gnu/store/b9aapwjz2nhri24imzy491fx86ng8jvz-libxau-1.0.8/lib:/gnu/store/07gpi7dx2rjs5v5n12q5b2sk7gxsliih-libxdmcp-1.1.2/lib:/gnu/store/cy16rapipmypb7qj49ncphjkkj9nqkzx-libbsd-0.8.7/lib:/gnu/store/ycj27z17m3n5qj1rwnyxdqkrk7li9712-libxshmfence-1.3/lib:/gnu/store/8w2i20d3gh80x0a7hvbkww8yyn5ky2j8-wayland-1.15.0/lib:/gnu/store/hp2j1cjrca3ghi14ikzhanx8yl41kihp-mesa-18.1.5/lib:/gnu/store/ppsylkcpw2fk2lkzhwjd60xyr9gjl70v-libffi-3.2.1/lib:/gnu/store/70825hjil6070g7cs3mmdnfwmhxgga36-expat-2.2.5/lib:/gnu/store/66h0jfk3k4wavw951ydkzv4x3wwgapkm-libdrm-2.4.92/lib:/gnu/store/l4lr0f5cjd0nbsaaf8b5dmcw1a1yypr3-glibc-2.27/lib:/gnu/store/vla5j7pbkpcp39lsdfsmz7m9azn48lr4-gcc-5.5.0-lib/lib:/gnu/store/fxiwj2wpp11sif613axdax7gmwzsg6kp-zlib-1.2.11/lib:/gnu/store/vla5j7pbkpcp39lsdfsmz7m9azn48lr4-gcc-5.5.0-lib/lib/gcc/x86_64-unknown-linux-gnu/5.5.0/../../..]
--8<---------------cut here---------------end--------------->8---

Then again, these are “.debuginfo” files so perhaps they are the result
of home-made ELF stripping (we don’t have this problem with “.debug”
files created with objcopy & co.).

I can see two short-term “solutions”:

  1. Remove those .debuginfo files prior to the ‘validate-runpath’
     phase.

  2. Set #:validate-runpath? #f.

Could you check in your build logs how those .debuginfo files are produced?

HTH!

Ludo’.