Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 68783 - prelink test cases fail
Summary: prelink test cases fail
Status: RESOLVED FIXED
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: [OLD] Unspecified (show other bugs)
Hardware: x86 Linux
: High normal (vote)
Assignee: Stefan Jones (RETIRED)
URL:
Whiteboard:
Keywords:
Depends on:
Blocks: 85027
  Show dependency tree
 
Reported: 2004-10-24 23:33 UTC by Brant Gurganus
Modified: 2005-05-27 10:56 UTC (History)
1 user (show)

See Also:
Package list:
Runtime testing required: ---


Attachments
failed test logs (logs.tar.bz2,4.20 KB, application/x-bzip)
2004-10-24 23:54 UTC, Brant Gurganus
Details
Patch adding bounds checking when looking for section header entries (section_overflow.diff,447 bytes, patch)
2004-10-26 10:25 UTC, Jaroslav Sladek
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Brant Gurganus 2004-10-24 23:33:06 UTC
Four of the test cases that are run by prelink's ebuild when makecheck is in FEATURES fail.

Reproducible: Always
Steps to Reproduce:
1. With "makecheck" in features, emerge prelink 20040707.
Actual Results:  
PASS: reloc1.sh
FAIL: reloc2.sh
PASS: reloc3.sh
PASS: reloc6.sh
PASS: reloc7.sh
PASS: reloc8.sh
PASS: reloc9.sh
PASS: reloc10.sh
PASS: reloc11.sh
PASS: shuffle1.sh
PASS: shuffle2.sh
PASS: shuffle3.sh
PASS: shuffle4.sh
PASS: shuffle5.sh
PASS: shuffle6.sh
PASS: shuffle7.sh
PASS: layout1.sh
PASS: layout2.sh
PASS: tls1.sh
PASS: tls2.sh
PASS: tls3.sh
PASS: tls4.sh
PASS: tls5.sh
PASS: tls6.sh
PASS: cxx1.sh
PASS: quick1.sh
PASS: cycle1.sh
PASS: cycle2.sh
FAIL: deps1.sh
FAIL: deps2.sh
FAIL: undosyslibs.sh
====================
4 of 31 tests failed
====================


Expected Results:  
No tests fail.

These fail with CFLAGS="" as well.

Portage 2.0.51-r2 (default-x86-2004.2, gcc-3.3.4, glibc-2.3.4.20040808-r1,
2.6.9-gentoo-r1 i686)
=================================================================
System uname: 2.6.9-gentoo-r1 i686 Mobile Intel(R) Pentium(R) 4 - M CPU 2.20GHz
Gentoo Base System version 1.4.16
distcc 2.16 i686-pc-linux-gnu (protocols 1 and 2) (default port 3632) [enabled]
ccache version 2.3 [enabled]
Autoconf: sys-devel/autoconf-2.59-r5
Automake: sys-devel/automake-1.8.5-r1
Binutils: sys-devel/binutils-2.14.90.0.8-r1
Headers:  sys-kernel/linux26-headers-2.6.8.1
Libtools: sys-devel/libtool-1.5.2-r5
ACCEPT_KEYWORDS="x86"
AUTOCLEAN="yes"
CFLAGS="-O3 -march=pentium4 -mcpu=pentium4 -maccumulate-outgoing-args
-fprefetch-loop-arrays -ftracer -pipe -fomit-frame-pointer"
CHOST="i686-pc-linux-gnu"
COMPILER=""
CONFIG_PROTECT="/etc /usr/X11R6/lib/X11/xkb /usr/kde/2/share/config
/usr/kde/3.3/env /usr/kde/3.3/share/config /usr/kde/3.3/shutdown
/usr/kde/3/share/config /usr/lib/mozilla/defaults/pref /usr/share/config
/var/qmail/control"
CONFIG_PROTECT_MASK="/etc/gconf /etc/terminfo /etc/env.d"
CXXFLAGS="-O3 -march=pentium4 -mcpu=pentium4 -maccumulate-outgoing-args
-fprefetch-loop-arrays -ftracer -pipe -fomit-frame-pointer"
DISTDIR="/usr/portage/distfiles"
FEATURES="autoaddcvs ccache distcc distlocks fixpackages maketest sandbox strict"
GENTOO_MIRRORS="ftp://hercules.cs.rose-hulman.edu/linux/gentoo"
MAKEOPTS="-j10"
PKGDIR="/usr/portage/packages"
PORTAGE_TMPDIR="/var/tmp"
PORTDIR="/usr/portage"
PORTDIR_OVERLAY=""
SYNC="rsync://hercules.cs.rose-hulman.edu/portage"
USE="X acpi alsa avi berkdb bitmap-fonts cdr crypt cups dga dvd encode esd f77
foomaticdb gdbm gif gnome gpm gstreamer gtk gtk2 imlib java jpeg kde ldap libg++
libwww mad mikmod mmap mmx mng motif mozilla mpeg mysql ncurses nls nptl
offensive oggvorbis opengl pam pdflib perl png pnp ppds python qt quicktime
readline samba sasl sdl slang spell sse ssl svg tcpd tiff truetype unicode wmf
x86 xml xml2 xmms xprint xv zlib"
Comment 1 Brant Gurganus 2004-10-24 23:49:07 UTC
I tried building and testing this version of prelink outside of portage completely and the tests still failed.  The undosyslibs.sh test did pass outside of portage though.
Comment 2 Brant Gurganus 2004-10-24 23:54:15 UTC
Created attachment 42545 [details]
failed test logs
Comment 3 Jaroslav Sladek 2004-10-25 08:04:13 UTC
I can only confirm this, my configuration is mostly the same, except I don't use distcc and ccache. Same tests fail, same errors. 

I was trying to figure out why, but didn't get very far. undosyslibs.sh seems to be merely confused by sandbox, the whole testscript does some wierd magic with copying system libraries to test directory, prelinking them in there and eventually undoing prelink and it fails when it tries to undo prelinking of libsandbox. deps?.sh fail also when attempting to undo prelink of some library that wasn't prelinked in the first place, although I have no idea why it wasn't. I don't know about reloc2.sh.
Comment 4 Stefan Jones (RETIRED) gentoo-dev 2004-10-25 08:53:11 UTC
make[2]: Entering directory `/home/saj/tmp/prelink/prelink-20040707/testsuite'
PASS: reloc1.sh
PASS: reloc2.sh
PASS: reloc3.sh
PASS: reloc6.sh
PASS: reloc7.sh
PASS: reloc8.sh
PASS: reloc9.sh
PASS: reloc10.sh
PASS: reloc11.sh
PASS: shuffle1.sh
PASS: shuffle2.sh
PASS: shuffle3.sh
PASS: shuffle4.sh
PASS: shuffle5.sh
PASS: shuffle6.sh
PASS: shuffle7.sh
PASS: layout1.sh
PASS: layout2.sh
PASS: tls1.sh
PASS: tls2.sh
PASS: tls3.sh
PASS: tls4.sh
PASS: tls5.sh
PASS: tls6.sh
PASS: cxx1.sh
PASS: quick1.sh
PASS: cycle1.sh
PASS: cycle2.sh
FAIL: deps1.sh
FAIL: deps2.sh
PASS: undosyslibs.sh
====================
2 of 31 tests failed
====================


And the deps tests only fail because of bugs in the check scripts. So most of the problems must be to do with your systems.
Comment 5 Jaroslav Sladek 2004-10-25 09:24:29 UTC
make[2]: Entering directory `/home/sladek/tmp/prelink/testsuite'
PASS: reloc1.sh
FAIL: reloc2.sh
PASS: reloc3.sh
(...)
PASS: cycle2.sh
FAIL: deps1.sh
FAIL: deps2.sh
PASS: undosyslibs.sh
====================
3 of 31 tests failed
====================


Ok, dep tests are bugs in testscript and undosyslibs only fails inside sandbox. So the really strange thing is only reloc2.sh. Only mention I was able to find on the Net was in Debian packages Changelog (http://packages.debian.org/changelogs/pool/main/p/prelink/prelink_0.0.20040908-1/changelog):

prelink (0.0.20040216-1) unstable; urgency=low
  (...)
  * Removed reloc2.sh test for all archs because it fails when it's built
    with optimizations. (closes: #233197)

However, I was playing with optimizations on and off, for prelink itself and for tested binary and it always failed with the same bug, ie.: 
../src/prelink -c ./prelink.conf -C ./prelink.cache --ld-library-path=. --dynamic-linker=./ld-linux.so.2 -y reloc2lib1.so > reloc2lib1.so.new
../src/prelink: reloc2lib1.so: prelinked file was modified

I may try playing with it in debugger whenever I have time, or testing it on different system, but I don't know if it will help much. Maybe testing different compiler would. 

My emerge info, if it helps:

Portage 2.0.51-r2 (default-x86-2004.2, gcc-3.3.4, glibc-2.3.4.20040808-r1, 2.6.9-gentoo-r1 i686)
=================================================================
System uname: 2.6.9-gentoo-r1 i686 Intel(R) Celeron(TM) CPU                1100MHz
Gentoo Base System version 1.4.16
Autoconf: sys-devel/autoconf-2.59-r5
Automake: sys-devel/automake-1.8.5-r1
Binutils: sys-devel/binutils-2.14.90.0.8-r1
Headers:  sys-kernel/linux26-headers-2.6.8.1-r1
Libtools: sys-devel/libtool-1.5.2-r5
ACCEPT_KEYWORDS="x86"
AUTOCLEAN="yes"
CFLAGS="-O2 -march=pentium3 -mcpu=pentium3 -ftracer -fprefetch-loop-arrays -fomit-frame-pointer -pipe"
CHOST="i686-pc-linux-gnu"
COMPILER=""
CONFIG_PROTECT="/etc /usr/X11R6/lib/X11/xkb /usr/kde/2/share/config /usr/kde/3.3/env /usr/kde/3.3/share/config /usr/kde/3.3/shutdown /usr/kde/3/share/config /usr/share/config /var/qmail/control"
CONFIG_PROTECT_MASK="/etc/gconf /etc/terminfo /etc/env.d"
CXXFLAGS="-O2 -march=pentium3 -mcpu=pentium3 -ftracer -fprefetch-loop-arrays -fomit-frame-pointer -pipe"
DISTDIR="/usr/portage/distfiles"
FEATURES="autoaddcvs ccache distlocks sandbox"
GENTOO_MIRRORS="http://mirrors.sec.informatik.tu-darmstadt.de/gentoo/ http://gentoo.inode.at/ ftp://ftp.tu-clausthal.de/pub/linux/gentoo/ ftp://linux.rz.ruhr-uni-bochum.de/gentoo-mirror/"
MAKEOPTS="-j2"
PKGDIR="/usr/portage/packages"
PORTAGE_TMPDIR="/var/tmp"
PORTDIR="/usr/portage"
PORTDIR_OVERLAY=""
SYNC="rsync://rsync.europe.gentoo.org/gentoo-portage"
USE="X alsa apache2 arts avi berkdb bitmap-fonts crypt cups encode flac foomaticdb gdbm gif gpm gtk gtk2 imlib java jpeg kde ldap libg++ libwww mad mikmod mmx mmx2 motif mpeg ncurses network nls nptl oggvorbis opengl oss pam pdflib perl pic png python qt quicktime readline sdl slang spell sse ssl svga tcpd truetype vim-with-x x86 xml2 xmms xprint xv zlib"
Comment 6 Jaroslav Sladek 2004-10-26 10:23:41 UTC
Ok, failure of reloc2 test may be actual bug in prelink. More detailed analysis follows.

Observation #1: this failure is connected with "strip -R .comment" command in reloc2.sh script. When it's removed (or replaced by normal strip) everything works.

Observation #2: reloc2 does fail when prelink is run with -y argument, which basically undoes prelinking, prelinks the executable again and checks if this new prelinked version is equivallent to the old one. What fails in reloc2 is just this final check, so prelink arrives at different file then the initial one.

Observation #3: further examination of original and newly prelinked file with readelf shows that those files really do differ in one or two bytes, which happen to fall inside .dynsym section. Specifially, the difference is in the value field of this entry:
Num:   Value  Size Type    Bind   Vis      Ndx Name
24: 00000000     0 SECTION LOCAL  DEFAULT   24
In original file (after stripping, before any prelinking) it's always 00000000, in prelinked file on my computer it's sometimes 08120a24, at other times 00000000, and on different computers I was able to arrive at all kinds of values.:)

Observation #4: this entry should contain address of section #24 from section headers table. However, there's no section #24 - it was removed by aforementioned "strip -R .comment" (while strip didn't remove entry from .dynsym section), so highest index in section number table is section #23.

Likely reason: function set_stt_section_values in src/dso.c is responsible for finding appropriate addresses for SECTION entries in .dynsym from section header table. It walks through .dynsym SECTION entries and for each it does find appropriate address from array of section headers using its index value, but it forgets to check that given index even exists in section headers and occassionally uses some random value outside of array. Note that this is probably not that dangerous by itself, since it only does this for nonexistent section and nobody is likely to look for address of nonexistent section in the first place. However, it also keeps array of ints to mark already visited sections, and this array also has the wrong size, so it may occassionally write after the array.

Fix: by only updating adresses of existing sections in .dynsym I was able to eliminate given problem on all computers I have access to:
PASS: reloc1.sh
PASS: reloc2.sh
PASS: reloc3.sh
(...)
FAIL: deps1.sh
FAIL: deps2.sh
PASS: undosyslibs.sh
====================
2 of 31 tests failed
====================

I'll attach this one line patch. Anybody can test it, but I wouldn't recommend actually installing such modified prelink. I don't know that much about ELF file structure and this may have broken more than it fixes. I guess this bug is probably worth reporting to the upstream anyway.

I hope this at least makes sense, and now I can actually concentrate on something else.:)
Comment 7 Jaroslav Sladek 2004-10-26 10:25:27 UTC
Created attachment 42642 [details, diff]
Patch adding bounds checking when looking for section header entries
Comment 8 Stefan Jones (RETIRED) gentoo-dev 2005-05-27 10:56:41 UTC
The newest version of prelink works fine :-) (just outside of the sandbox)