Subject: bin/1146: ld.so fails after installing new minor version of shared library
To: None <gnats-admin@sun-lamp.pc.cs.cmu.edu>
From: None <gson@araneus.pp.fi>
List: netbsd-bugs
Date: 06/20/1995 05:20:15
>Number:         1146
>Category:       bin
>Synopsis:       ld.so fails after installing new minor version of shared library
>Confidential:   no
>Severity:       serious
>Priority:       high
>Responsible:    bin-bug-people (Utility Bug People)
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Tue Jun 20 05:20:13 1995
>Originator:     Andreas Gustafsson
>Organization:
Araneus Information Systems Oy
>Release:        NetBSD-current i386 binary snapshot of May 15, 1995
>Environment:

System: NetBSD araneus.pp.fi 1.0A NetBSD 1.0A (GUANO) #13: Tue May 30 09:12:20 EET DST 1995 root@araneus.pp.fi:/usr/src/sys/arch/i386/compile/GUANO i386

The bug also exists in earlier versions such as NetBSD 1.0beta.

>Description:

Installing a new minor version of a shared library in a directory that
has been designated as a library directory by use of ldconfig (not
LD_LIBRARY_PATH) causes ld.so to fail to locate _any_ version of
the library when attempting to run an existing binary that was linked
against an earlier version of the library.

>How-To-Repeat:

Repeat by running the following shell script.

# This is a shell archive.  Save it in a file, remove anything before
# this line, and then unpack it by entering "sh file".  Note, it may
# create directories; files and directories will be owned by you and
# have default permissions.
#
# This archive contains:
#
#	shlibtest
#
echo x - shlibtest
sed 's/^X//' >shlibtest << 'END-of-shlibtest'
X#!/bin/sh
X#
X# This script demonstrates a bug in the NetBSD shared
X# library system.  It needs to be run as root. 
X# Beware that the script creates some files in the current
X# directory, modifies the shared library cache, and
X# temporarily installs a shared library in /usr/local/lib.
X#
X
X# make sure we start out in a clean state
X
Xrm -f /usr/local/lib/libfoo.*
Xldconfig /usr/local/lib
Xunset LD_LIBRARY_PATH; export LD_LIBRARY_PATH
X
X# if this line is uncommented, things will actually work
X# LD_LIBRARY_PATH=/usr/local/lib
X
X# build and install an initial library version and link an 
X# application against it
X
Xcat >foo.c <<\END
Xfoo() { printf("this is libfoo version 3.30\n"); }
XEND
X
Xcc -fpic -c foo.c
Xrm -f libfoo.a
Xar r libfoo.a foo.o
Xld -Bshareable -Bforcearchive -o libfoo.so.3.30 libfoo.a
X
Xmv libfoo.so.3.30 /usr/local/lib/
Xldconfig /usr/local/lib
X
Xcat >app.c <<\END
Xmain() 
X{
X  foo();
X}
XEND
X
Xcc app.c -L/usr/local/lib -lfoo -o app
X
X# test the application
X
X./app
X
X# upgrade the library to a new version
X
Xcat >foo.c <<\END
Xfoo() { printf("this is libfoo version 3.31\n"); }
XEND
X
Xcc -fpic -c foo.c
Xrm -f libfoo.a
Xar r libfoo.a foo.o
Xld -Bshareable -Bforcearchive -o libfoo.so.3.31 libfoo.a
X
Xmv libfoo.so.3.31 /usr/local/lib/
Xldconfig /usr/local/lib
X
X# re-test the application; it will fail with the error message
X# "ld.so: app: libfoo.so.3.30: No such file or directory"
X
X./app
X
X# you probably want to re-run ldconfig with your local configuration now
END-of-shlibtest
exit

>Fix:

As a workaround, add the library directory to LD_LIBRARY_PATH.
I don't have a real fix.
>Audit-Trail:
>Unformatted: