NetBSD Problem Report #42811
From njoly@lanfeust.sis.pasteur.fr Sun Feb 14 22:04:52 2010
Return-Path: <njoly@lanfeust.sis.pasteur.fr>
Received: from mail.netbsd.org (mail.netbsd.org [204.152.190.11])
by www.NetBSD.org (Postfix) with ESMTP id E5EC463BDFE
for <gnats-bugs@gnats.NetBSD.org>; Sun, 14 Feb 2010 22:04:51 +0000 (UTC)
Message-Id: <20100214220446.233E6DC9B9@lanfeust.sis.pasteur.fr>
Date: Sun, 14 Feb 2010 23:04:46 +0100 (CET)
From: njoly@pasteur.fr
Reply-To: njoly@pasteur.fr
To: gnats-bugs@gnats.NetBSD.org
Subject: ldd(1) does not handle loops gracefully
X-Send-Pr-Version: 3.95
>Number: 42811
>Category: bin
>Synopsis: ldd(1) does not handle loops gracefully
>Confidential: no
>Severity: non-critical
>Priority: low
>Responsible: skrll
>State: closed
>Class: sw-bug
>Submitter-Id: net
>Arrival-Date: Sun Feb 14 22:05:01 +0000 2010
>Closed-Date: Tue Feb 23 10:52:05 +0000 2010
>Last-Modified: Sat Mar 06 22:50:02 +0000 2010
>Originator: Nicolas Joly
>Release: NetBSD 5.99.24
>Organization:
Institut Pasteur
>Environment:
System: NetBSD lanfeust.sis.pasteur.fr 5.99.24 NetBSD 5.99.24 (LANFEUST) #0: Fri Feb 12 12:12:29 CET 2010 njoly@lanfeust.sis.pasteur.fr:/local/src/NetBSD/obj.amd64/sys/arch/amd64/compile/LANFEUST amd64
Architecture: x86_64
Machine: amd64
>Description:
While checking dynamic libraries dependencies in one of my systems, i found
the ldd(1) crashed with 2 of them: libelf.so and libnvpair.so.
njoly@lanfeust [~]> ldd /usr/lib/libelf.so
/usr/lib/libelf.so:
zsh: segmentation fault (core dumped) ldd /usr/lib/libelf.so
A further look, show that those 2 libraries have themselves as dependencies:
njoly@lanfeust [~]> objdump x /usr/lib/libelf.so
/usr/lib/libelf.so: file format elf64-x86-64
/usr/lib/libelf.so
architecture: i386:x86-64, flags 0x00000150:
HAS_SYMS, DYNAMIC, D_PAGED
start address 0x0000000000002f60
[...]
Dynamic Section:
NEEDED libelf.so.0
NEEDED libc.so.12
SONAME libelf.so.0
INIT 0x0000000000002b20
[...]
In that case, ldd will enter a recursive loop trying to display libelf.so
needed libs, starting with itself ...
njoly@lanfeust [~]> gdb ldd ldd.core
GNU gdb 6.5
[...]
Core was generated by `ldd'.
Program terminated with signal 11, Segmentation fault.
#0 0x00000000004019ba in print_needed (obj=0x7f7ffdff2200, fmt1=0x0, fmt2=0x0)
at /local/src/NetBSD/src/usr.bin/ldd/ldd.c:286
286 {
(gdb) bt
#0 0x00000000004019ba in print_needed (obj=0x7f7ffdff2200, fmt1=0x0, fmt2=0x0)
at /local/src/NetBSD/src/usr.bin/ldd/ldd.c:286
#1 0x00000000004019fa in print_needed (obj=0x7f7ffdff2200, fmt1=0x0, fmt2=0x0)
at /local/src/NetBSD/src/usr.bin/ldd/ldd.c:293
#2 0x00000000004019fa in print_needed (obj=0x7f7ffdff2200, fmt1=0x0, fmt2=0x0)
at /local/src/NetBSD/src/usr.bin/ldd/ldd.c:293
[...]
(gdb) up
#1 0x00000000004019fa in print_needed (obj=0x7f7ffdff2200, fmt1=0x0, fmt2=0x0)
at /local/src/NetBSD/src/usr.bin/ldd/ldd.c:293
293 print_needed(needed->obj, fmt1, fmt2);
(gdb) p *needed->obj
$2 = {magic = 0, version = 0, next = 0x7f7ffdff2400,
path = 0x7f7ffdff1140 "/usr/lib/libelf.so.0", refcount = 2, dl_refcount = 0,
mapbase = 0x7f7ffd000000 <Address 0x7f7ffd000000 out of bounds>,
[...]
(gdb) up
#2 0x00000000004019fa in print_needed (obj=0x7f7ffdff2200, fmt1=0x0, fmt2=0x0)
at /local/src/NetBSD/src/usr.bin/ldd/ldd.c:293
293 print_needed(needed->obj, fmt1, fmt2);
(gdb) p *needed->obj
$3 = {magic = 0, version = 0, next = 0x7f7ffdff2400,
path = 0x7f7ffdff1140 "/usr/lib/libelf.so.0", refcount = 2, dl_refcount = 0,
mapbase = 0x7f7ffd000000 <Address 0x7f7ffd000000 out of bounds>,
[...]
>How-To-Repeat:
echo "void foo(void) {}" >foo.c
cc -shared -fPIC -o libfoo.so foo.c
cc -shared -fPIC -Wl,-rpath,. -o libbar.so foo.c -L. -lfoo
mv libbar.so libfoo.so
ldd ./libfoo.so
>Fix:
>Release-Note:
>Audit-Trail:
Responsible-Changed-From-To: bin-bug-people->skrll
Responsible-Changed-By: skrll@NetBSD.org
Responsible-Changed-When: Tue, 23 Feb 2010 10:52:05 +0000
Responsible-Changed-Why:
mine
State-Changed-From-To: open->closed
State-Changed-By: skrll@NetBSD.org
State-Changed-When: Tue, 23 Feb 2010 10:52:05 +0000
State-Changed-Why:
I fixed it.
From: Nick Hudson <skrll@netbsd.org>
To: gnats-bugs@gnats.NetBSD.org
Subject: PR/48211 CVS commit: src/usr.bin/ldd
Date: Tue, 23 Feb 2010 08:23:24 +0000
Modified Files:
src/usr.bin/ldd: ldd.c
Log Message:
Mark each object as printed as visited and then print.
Fixes PR/48211.
As a side effect the libraries are printed in, imo, a better order.
To generate a diff of this commit:
cvs rdiff -u -r1.12 -r1.13 src/usr.bin/ldd/ldd.c
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
From: Stephen Borrill <sborrill@netbsd.org>
To: gnats-bugs@gnats.NetBSD.org
Cc:
Subject: PR/42811 CVS commit: [netbsd-5] src/usr.bin/ldd
Date: Sat, 6 Mar 2010 22:48:22 +0000
Module Name: src
Committed By: sborrill
Date: Sat Mar 6 22:48:22 UTC 2010
Modified Files:
src/usr.bin/ldd [netbsd-5]: ldd.c
Log Message:
Pull up the following revisions(s) (requested by skrll in ticket #1318):
usr.bin/ldd/ldd.c: revision 1.13
Mark each object as printed as visited and then print. Fixes PR/42811.
Improve print order.
To generate a diff of this commit:
cvs rdiff -u -r1.2.12.2 -r1.2.12.3 src/usr.bin/ldd/ldd.c
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
>Unformatted:
(Contact us)
$NetBSD: query-full-pr,v 1.39 2013/11/01 18:47:49 spz Exp $
$NetBSD: gnats_config.sh,v 1.8 2006/05/07 09:23:38 tsutsui Exp $
Copyright © 1994-2007
The NetBSD Foundation, Inc. ALL RIGHTS RESERVED.