Subject: lib/5363: C++ program binaries from 1.2 dump core under 1.3
To: None <gnats-bugs@gnats.netbsd.org>
From: Andreas Gustafsson <gson@araneus.fi>
List: netbsd-bugs
Date: 04/25/1998 20:12:34
>Number:         5363
>Category:       lib
>Synopsis:       C++ program binaries from 1.2 dump core under 1.3
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    lib-bug-people (Library Bug People)
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Sat Apr 25 10:20:00 1998
>Last-Modified:
>Originator:     Andreas Gustafsson
>Organization:
Araneus Information Systems Oy
>Release:        1.3
>Environment:

System: NetBSD guava.araneus.fi 1.3 NetBSD 1.3 (GUAVA) #0: Thu Feb 12 12:46:34 EET 1998 gson@guava.araneus.fi:/z/src/sys/arch/i386/compile/GUAVA i386


>Description:

Certain C++ program binaries built on a NetBSD 1.2 system will start
dumping core when the system is upgraded to NetBSD 1.3.  Specifically,
this happens to programs using the strstream class from libstdc++.

This appears to be caused by an incompatible change to the layout of
"struct _IO_str_fields" in libstdc++ some time between the 1.2 and 1.3
releases (the _len field was removed).

There would not be a problem if the major version number of
libstdc++.so had been incremented when the change was made, but it was
not (only the minor version number was incremented).  Thus, when a
machine is upgraded to NetBSD 1.3, programs that were previously using
libstdc++.so.0.0 will start using the newly installed, incompatible
libstdc++.so.0.1.

Incidentally, it may also be worth investigating whether the alleged
alignment problem of PR #3417 could be explained by a version mismatch
between the libstdc++.so file and header files of the affected system(s).

>How-To-Repeat:

NetBSD-1.2$ cat test.cc
#include <iostream.h>
#include <strstream.h>
int main(int argc, char **argv)
{
    ostrstream os;
    os << "Hello, world\n" << ends;
    cout << os.str();
}
NetBSD-1.2$ c++ test.cc
NetBSD-1.2$ a.out
Hello, world
NetBSD-1.2$ ldd a.out
a.out:
        -lstdc++.0 => /usr/lib/libstdc++.so.0.0 (0x1001a000)
        -lm.0 => /usr/lib/libm.so.0.1 (0x10059000)
        -lc.12 => /usr/lib/libc.so.12.5 (0x10070000)

(...upgrade to 1.3, or simply copy a.out to an 1.3 system...)

NetBSD-1.3$ a.out
Bus error (core dumped)
NetBSD-1.3$ ldd a.out
a.out:
        -lstdc++.0 => /usr/lib/libstdc++.so.0.1 (0x4001b000)
        -lm.0 => /usr/lib/libm.so.0.1 (0x40059000)
        -lc.12 => /usr/lib/libc.so.12.20 (0x40072000)

>Fix:

Rename /usr/lib/libstdc++.so.0.1 to libstdc++.so.1.0, then rebuild any
programs that depended on 0.1.
>Audit-Trail:
>Unformatted: