A bug in g++ exceptions on 7?

gnn at freebsd.org gnn at freebsd.org
Tue Apr 15 09:59:56 UTC 2008


Howdy,

We believe we've found a bug in the libgcc or libstdc++ library (not
sure which one) packaged with the gcc43 port in fbsd7 on an Intel
x86-64.  A program linked against those libraries aborts when an
exception is thrown.  It does not abort if -lpthread is added to the
link line, even though the program does not use threads.  I believe
the problem is related to the pthread stubs in libgcc, but I don't
know enough to find the exact problem or fix it.  An example is below.

My system:
>uname -a
FreeBSD testlab5 7.0-STABLE FreeBSD 7.0-STABLE #1: Thu Feb 28 10:06:47 EST 2008
 root at builder:/usr/obj/usr/sources/FreeBSD.7/src/sys/GENERIC amd64
>which g++43
/usr/local/bin/g++43
>g++43 --version
g++43 (GCC) 4.3.1 20080313 (prerelease)
etc.
>echo $LD_LIBRARY_PATH
/usr/local/lib/gcc-4.3.1

Sample program. 
When compiled with "g++43 test.cc" , it aborts upon the throw.
When compiled with "g++43 test.cc -lpthread", it runs correctly.

#include <stdio.h>
int main(int argc, char* argv[])
{
    try {
        throw 1;
    }
    catch (...) {
        printf("Caught exception\n");
    }
}

Again, it only aborts when omitting -lpthread AND using the dynamic
libs in /usr/local/lib/gcc-4.3.1.  If we unsetenv LD_LIBRARY_PATH,
libraries are loaded from the base fbsd7 installation in /usr/lib,
which works.

Thoughts?

BTW We don't have a compiler issues mailing list I notice.

Later,
George


More information about the freebsd-stable mailing list