[nSLUG] Help? libstdc++ question/confusion

George N. White III gnwiii at gmail.com
Wed Jan 14 12:50:07 AST 2009


On Wed, Jan 14, 2009 at 2:52 AM, Mike Spencer <mspencer at tallships.ca> wrote:
>
> Summary: App works with config/libs on 2.4 kernel.  Fails with 2.6
>         kernel. Problem with libstdc++-libc6.1-1.so.2 apparently
>         hard-coded in a program.

There are changes to the internals of glib and libstdc++, so you either
recompile or use compatibility libraries.  It has been a while since I
built those libraries, but think there was an option to include support
for older versions when making a current libc and libstdc++.    Our
mission critical stuff is on RHEL, who have the compat libraries
as optional installs, but I recall reading complaints that Ubuntu
does not.

There may also be some older code that runs afoul of "security"
patches in current versions.   For some legacy apps I had to
build libraries with the patches reversed to use until the program's
authors made the required changes.

In extreme cases, people resort to running the older kernal in a
virtual machine.

> Details:
>
> I'm trying to run a rather old app [1] on a Slackware 12.1 install with
> 2.6 kernel.  I get:
>
>     Error while loading shared libraries: libstdc++-libc6.1-1.so.2
>     No such file or directory
>
> Sure enough, that lib doesn't exist in the new install on nudel.
>
> Okay, I look on my working machine (named bogus, Slak 10.1, 2.4
> kernel) and find:
>
>     bogus% cd /usr/i486-slackware-linux/lib/
>
>     bogus% ls -l libstdc++-libc6.1-1.so.2
>
>        libstdc++-libc6.1-1.so.2 -> libstdc++-2-libc6.1-1-2.9.0.so
>
>     bogus% ls -l libstdc++-2-libc6.1-1-2.9.0.so
>
>        libstdc++-2-libc6.1-1-2.9.0.so
>
> So I copy the real lib over to the same dir on the new box (nudel),
> create the corresponding symlink:
>
>     nudel-root$  mount bogus:/
>
>     nudel-root$ pwd
>
>      /usr/i486-slackware-linux/lib
>
>    nudel-root$ cp \
>
>      /mnt/bogus/usr/i486-slackware-linux/lib/libstdc++-2-libc6.1-1-2.9.0.so .
>
>    nudel-root$ ln -s libstdc++-2-libc6.1-1-2.9.0.so  libstdc++-libc6.1-1.so.2
>
> and now the app in question segfaults.

Yes, because the underlying interfaces have changed.  It may help to
use straces and/or gdb to indetify the call that fails -- you can see if the
change is covered in a compatibility library or was judged insecure, in
which case there may not be an easy fix.

> If I remove the symlink and recreate it pointing at either of the
> newer lib versions, libstdc++-3-libc6*, it also segfaults.
>
> What can I do to fix this?
>
> Why does it all worn on bogus but not on nudel?
>
> (Yes, I ran ldconfig on nudel after each change and
>  /usr/i486-slackware-linux/lib is listed in /etc/ld.so.conf.)
>
> I find this lib management stuff way more confusing than writing or
> even debugging C code.  I don't even know where to look for a lucid
> description of what the various libc* libraries do, how they differ,
> how they're systematically (?!) named and why there are so many that
> are just symlinks.  So I haven't doggedly documented, listed and
> researched this in tedious detail because I don't really know where to
> start.

Use the sources for the libraries.

> Really hoping for a helpful clue here.

I just learned about bashian roulette:

bash-3.1# (($RANDOM%6)) || echo 'Oops!'

where "echo 'Oops!'" is often replaced by "rm -rf /"
1 in 6 chance your library problems will suddenly seem
insignificant.

-- 
George N. White III <aa056 at chebucto.ns.ca>
Head of St. Margarets Bay, Nova Scotia



More information about the nSLUG mailing list