Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!

Bug 433778

Summary: sys-devel/prelink-20120628: prelink: gelf_getphdr.c:120: gelf_getphdr: Unexpected error: Resource temporarily unavailable.
Product: Gentoo Linux Reporter: Dennis Schridde <dschridde+gentoobugs>
Component: [OLD] Core systemAssignee: Gentoo Toolchain Maintainers <toolchain>
Status: RESOLVED FIXED    
Severity: normal    
Priority: Normal    
Version: unspecified   
Hardware: All   
OS: Linux   
Whiteboard:
Package list:
Runtime testing required: ---
Attachments: prelink.strace.log
fix-libgelf-linking.patch
disable local gelf in ebuild

Description Dennis Schridde 2012-09-03 12:10:36 UTC
Prelink stopped working on my machine:

# cat /var/log/prelink.log 
/usr/sbin/prelink -av -mR -f
prelink: gelf_getphdr.c:120: gelf_getphdr: Unexpected error: Resource temporarily unavailable.
Prelink failed with return value 134

# emerge --info
Portage 2.2.0_alpha123 (default/linux/amd64/10.0/desktop/kde, gcc-4.7.1, glibc-2
.15-r2, 3.5.3-gentoo x86_64)
=================================================================
System uname: Linux-3.5.3-gentoo-x86_64-AMD_Athlon-tm-_64_X2_Dual_Core_Processor
_5000+-with-gentoo-2.2
Timestamp of tree: Fri, 31 Aug 2012 07:45:01 +0000
distcc 3.2rc1 x86_64-pc-linux-gnu [disabled]
app-shells/bash:          4.2_p37
dev-java/java-config:     2.1.12
dev-lang/python:          2.7.3-r2, 3.2.3-r1
dev-util/cmake:           2.8.9
dev-util/pkgconfig:       0.27.1
sys-apps/baselayout:      2.2
sys-apps/openrc:          0.10.5
sys-apps/sandbox:         2.6
sys-devel/autoconf:       2.13, 2.69
sys-devel/automake:       1.9.6-r3, 1.10.3, 1.11.6, 1.12.3
sys-devel/binutils:       2.22.90
sys-devel/gcc:            4.7.1
sys-devel/gcc-config:     1.7.3
sys-devel/libtool:        2.4.2
sys-devel/make:           3.82-r3
sys-kernel/linux-headers: 3.5 (virtual/os-headers)
sys-libs/glibc:           2.15-r2
Repositories: gentoo systemd local kde sunrise g-ctan
ACCEPT_KEYWORDS="amd64 ~amd64"
ACCEPT_LICENSE="* -@EULA"
CBUILD="x86_64-pc-linux-gnu"
CFLAGS="-pipe -O2 -march=athlon64-sse3"
CHOST="x86_64-pc-linux-gnu"
CONFIG_PROTECT="/etc /usr/share/config /usr/share/gnupg/qualified.txt /usr/share
/openvpn/easy-rsa /usr/share/themes/oxygen-gtk/gtk-2.0 /usr/share/themes/oxygen-
gtk/gtk-3.0 /var/lib/neatx/home"
CONFIG_PROTECT_MASK="${EPREFIX}/etc/gconf /etc/ca-certificates.conf /etc/env.d /
etc/fonts/fonts.conf /etc/gconf /etc/gentoo-release /etc/php/apache2-php5.4/ext-
active/ /etc/php/cgi-php5.4/ext-active/ /etc/php/cli-php5.4/ext-active/ /etc/rev
dep-rebuild /etc/sandbox.d /etc/terminfo /etc/texmf/language.dat.d /etc/texmf/la
nguage.def.d /etc/texmf/updmap.d /etc/texmf/web2c"
CXXFLAGS="-pipe -O2 -march=athlon64-sse3"
DISTDIR="/var/cache/portage/distfiles"
EMERGE_DEFAULT_OPTS="--depclean-lib-check n --with-bdeps y --keep-going"
FCFLAGS="-O2 -pipe"
FEATURES="assume-digests binpkg-logs buildsyspkg compressdebug config-protect-if
-modified distlocks ebuild-locks fixlafiles news parallel-fetch parse-eapi-ebuil
d-head preserve-libs protect-owned sandbox sfperms strict unknown-features-warn 
unmerge-logs unmerge-orphans userfetch userpriv usersandbox usersync xattr"
FFLAGS="-O2 -pipe"
GENTOO_MIRRORS="ftp://linux.rz.ruhr-uni-bochum.de/gentoo-mirror/ ftp://linux.rz.
ruhr-uni-bochum.de/gentoo-mirror/ http://distfiles.gentoo.org"
LANG="en_GB.UTF-8"
LDFLAGS="-Wl,-O1 -Wl,--as-needed -Wl,--hash-style=gnu -Wl,--hash-style=gnu"
LINGUAS="de"
MAKEOPTS="-j3"
PKGDIR="/var/cache/portage/packages"
PORTAGE_COMPRESS="xz"
PORTAGE_CONFIGROOT="/"
PORTAGE_RSYNC_OPTS="--recursive --links --safe-links --perms --times --compress 
--force --whole-file --delete --stats --human-readable --timeout=180 --exclude=/
distfiles --exclude=/local --exclude=/packages"
PORTAGE_TMPDIR="/var/tmp"
PORTDIR="/var/cache/portage/gentoo"
PORTDIR_OVERLAY="/var/cache/portage/layman/systemd /var/cache/portage/local /var
/cache/portage/overlays/kde /var/cache/portage/overlays/sunrise /var/lib/g-ctan"

SYNC="rsync://gentoo.kynes.de:800/gentoo-portage"
USE="3dnow 3dnowext X a52 aac acl acpi alsa amd64 apache2 bash-completion berkdb
 bluetooth branding bzip2 cairo caps cdda cdr cjk cli consolekit cracklib crypt 
cups cxx dbus declarative dri dts dvb dvd dvdr emboss encode exif fam ffmpeg fir
efox flac fortran gdbm gif gimp gpm gtk iconv ipv6 jpeg jpeg2k kde kipi latex lc
ms ldap libnotify mad mmx mmxext mng modules mp3 mp4 mpeg mplayer mudflap multil
ib mysql ncurses nls nptl ogg openal openexr opengl openmp oss pam pango pch pcr
e pdf phonon php plasma png policykit ppds pppd pulseaudio qt3support qt4 readli
ne samba sdl semantic-desktop session speex spell sse sse2 sse3 ssl startup-noti
fication subversion svg tcpd theora threads tiff truetype udev udisks unicode up
ower usb vorbis x264 xattr xcb xcomposite xinerama xml xscreensaver xv xvid zlib
" ALSA_CARDS="hda-intel" ALSA_PCM_PLUGINS="adpcm alaw asym copy dmix dshare dsno
op empty extplug file hooks iec958 ioplug ladspa lfloat linear meter mmap_emul m
ulaw multi null plug rate route share shm softvol" APACHE2_MODULES="actions alia
s auth_basic authn_alias authn_anon authn_dbm authn_default authn_file authz_dbm
 authz_default authz_groupfile authz_host authz_owner authz_user autoindex cache
 cgi cgid dav dav_fs dav_lock deflate dir disk_cache env expires ext_filter file
_cache filter headers include info log_config logio mem_cache mime mime_magic ne
gotiation rewrite setenvif speling status unique_id userdir usertrack vhost_alia
s" CALLIGRA_FEATURES="stage words flow sheets" CAMERAS="ptp2" COLLECTD_PLUGINS="
df interface irq load memory rrdtool swap syslog" DRACUT_MODULES="btrfs systemd"
 ELIBC="glibc" GPSD_PROTOCOLS="ashtech aivdm earthmate evermore fv18 garmin garm
intxt gpsclock itrax mtk3301 nmea ntrip navcom oceanserver oldstyle oncore rtcm1
04v2 rtcm104v3 sirf superstar2 timing tsip tripmate tnt ubx" GRUB_PLATFORMS="pc"
 INPUT_DEVICES="evdev joystick" KERNEL="linux" LCD_DEVICES="bayrad cfontz cfontz
633 glk hd44780 lb216 lcdm001 mtxorb ncurses text" LIBREOFFICE_EXTENSIONS="prese
nter-console presenter-minimizer" LINGUAS="de" LIRC_DEVICES="devinput" PHP_TARGE
TS="php5-3" PYTHON_TARGETS="python3_2 python2_7" RUBY_TARGETS="ruby18 ruby19" US
ERLAND="GNU" VIDEO_CARDS="radeon r600" XTABLES_ADDONS="quota2 psd pknock lscan l
ength2 ipv4options ipset ipp2p iface geoip fuzzy condition tee tarpit sysrq stea
l rawnat logmark ipmark dhcpmac delude chaos account"
Unset:  CPPFLAGS, CTARGET, INSTALL_MASK, LC_ALL, PORTAGE_BUNZIP2_COMMAND, PORTAG
E_COMPRESS_FLAGS, PORTAGE_RSYNC_EXTRA_OPTS, USE_PYTHON
Comment 1 SpanKY gentoo-dev 2012-09-04 20:35:41 UTC
if you run it by hand, does it work ?  do you have limits in place ?  if it fails by hand and you run it through strace, can you post the log ?
Comment 2 Dennis Schridde 2012-09-04 21:00:19 UTC
Created attachment 322944 [details]
prelink.strace.log

(In reply to comment #1)
> if you run it by hand, does it work ?
No, it does not.

> do you have limits in place ?
# grep -v ^# /etc/security/limits.conf
-- is empty --

> if it fails by hand and you run it through strace, can you post the log ?
Please find the log attached.
Comment 3 Andrey Ponomarenko 2012-10-05 14:02:59 UTC
This is due to prelink is trying to run a wrong implementation of gelf_getphdr function from the libelf system library instead of using its own implementation of this function in the libgelf static library (gelf/.libs/libgelf.a).

Try this patch from the ROSA Linux: https://abf.rosalinux.ru/import/prelink/blob/rosa2012.1/fix-libgelf-linking.patch

And rebuild prelink.
Comment 4 Dennis Schridde 2012-10-05 14:20:36 UTC
(In reply to comment #3)
> This is due to prelink is trying to run a wrong implementation of
> gelf_getphdr function from the libelf system library
You refer to dev-libs/libelf? I do not even have that installed.
Comment 5 Dennis Schridde 2012-10-05 14:21:24 UTC
(In reply to comment #4)
> (In reply to comment #3)
> > This is due to prelink is trying to run a wrong implementation of
> > gelf_getphdr function from the libelf system library
> You refer to dev-libs/libelf? I do not even have that installed.
Oh, n/m, it is also included in dev-libs/elfutils-0.155.

So that means that dev-libs/elfutils-0.155 is broken?
Comment 6 Dennis Schridde 2012-10-05 15:03:17 UTC
Created attachment 325720 [details, diff]
fix-libgelf-linking.patch

(In reply to comment #3)
> Try this patch from the ROSA Linux - And rebuild prelink.
The patch appears broken. It modifies the intermediate file Makefile.in, while it should probably modify Makefile.am instead.

With attached patch, it compiles and the resulting prelink appears to work (at least no error message anymore).

However, when leaving in the -all-static flag, I get multiple definition errors :
/usr/lib/gcc/x86_64-pc-linux-gnu/4.7.2/../../../../lib64/libelf.a(gelf_fsize.o): In function `gelf_fsize':
(.text+0x0): multiple definition of `gelf_fsize'
../gelf/.libs/libgelf.a(gelf.o):gelf.c:(.text+0x40): first defined here
/usr/lib/gcc/x86_64-pc-linux-gnu/4.7.2/../../../../lib64/libelf.a(gelf_getehdr.o): In function `gelf_getehdr':
(.text+0x110): multiple definition of `gelf_getehdr'
../gelf/.libs/libgelf.a(gelf.o):gelf.c:(.text+0xd0): first defined here

I think that this symbol layering/replacement is probably a bit dodgy, and instead of hacking in custom versions of gelf_fsize and gelf_getehdr, dev-libs/elfutils-0.155 should probably be fixed.
Comment 7 Andrey Ponomarenko 2012-10-05 15:08:24 UTC
No, elfutils are OK.

The only broken thing if Prelink, but it can be fixed by changing two lines in the Makefile (see patch).
Comment 8 Andrey Ponomarenko 2012-10-05 15:09:33 UTC
The -all-static flag should be removed.
Comment 9 Dennis Schridde 2012-10-05 15:33:03 UTC
(In reply to comment #7)
> No, elfutils are OK.
> 
> The only broken thing if Prelink, but it can be fixed by changing two lines
> in the Makefile (see patch).
But prelink seems to hook in some custom functions, namely gelf_fsize and gelf_getehdr, which appears to easily create problems.
Comment 10 Andrey Ponomarenko 2012-10-05 21:09:58 UTC
(In reply to comment #6)
> Created attachment 325720 [details, diff] [details, diff]
> fix-libgelf-linking.patch
> 
> (In reply to comment #3)
> > Try this patch from the ROSA Linux - And rebuild prelink.
> The patch appears broken. It modifies the intermediate file Makefile.in,
> while it should probably modify Makefile.am instead.
> 
> With attached patch, it compiles and the resulting prelink appears to work
> (at least no error message anymore).

Thanks for your improvements in the patch!

> 
> I think that this symbol layering/replacement is probably a bit dodgy, and
> instead of hacking in custom versions of gelf_fsize and gelf_getehdr,
> dev-libs/elfutils-0.155 should probably be fixed.

Yes, this seems to be a right way. But it may affect or even break the whole system. It should be investigated why prelink and libelf have different implementations of gelf_* symbols.
Comment 11 SpanKY gentoo-dev 2012-12-25 07:40:36 UTC
Created attachment 333248 [details, diff]
disable local gelf in ebuild

does this work for you ?
Comment 12 SpanKY gentoo-dev 2013-05-11 16:27:03 UTC
(In reply to comment #11)

ping ?
Comment 13 Dennis Schridde 2013-05-11 20:27:03 UTC
(In reply to comment #11)
> does this work for you ?

No, same error as before.

As I understand your patch, it disables the copy of libelf that is included in prelink, which is exactly the opposite of the actual fix (or call it workaround):

(In reply to comment #3)
> This is due to prelink is trying to run a wrong implementation of
> gelf_getphdr function from the libelf system library instead of using its
> own implementation of this function in the libgelf static library
> (gelf/.libs/libgelf.a).

--> Unless the system libelf is patched with whatever patch prelink needs, prelink has to use its own implementation.
Comment 14 SpanKY gentoo-dev 2016-04-03 01:27:07 UTC
please retest with prelink-20151030