public inbox for gcc-help@gcc.gnu.org
 help / color / mirror / Atom feed
* Segmentation faults with static linking
@ 2006-06-22 17:30 Jon.Barks
  0 siblings, 0 replies; only message in thread
From: Jon.Barks @ 2006-06-22 17:30 UTC (permalink / raw)
  To: gcc-help

Hi,

I am getting Segmentation faults when statically linking gcc-4.0.2
libraries on AIX 5.1 (RS/6000).  Below is the test program that simply
throws exceptions.

#include <cstdlib>
#include <iostream>

void sinser()
{
        try {
            throw 1;
            } catch (int e) {
              std::cerr  << "Exception caught: " << e;
              std::cerr << std::endl;
              throw;
            }
}

int main()
{
  try {
      sinser();
     }  catch (int e) {
      std::cerr  << "Exception caught: " << e;
      std::cerr << std::endl;
    }
}

When the program is dynamically linked (g++ -g catch.cc) the executable
works fine.  
The ldd output is:
/usr/local/lib/gcc/powerpc-ibm-aix5.1.0.0/4.0.3/../../../libgcc_s.a(shr.
o)
/usr/local/lib/gcc/powerpc-ibm-aix5.1.0.0/4.0.3/../../../libstdc++.a(lib
stdc++.so.6)
/usr/lib/libcrypt.a(shr.o)
/usr/lib/libc.a(shr.o)

When the gcc libraries are statically linked, either completely (g++ -g
-static catch.cc) or specifically (g++ -g -nodefaultlibs -Wl,-bdynamic
-lc -lcrypt -Wl,-bnoquiet -Wl,-bstatic -lgcc -lgcc_eh -lstdc++ catch.cc)
a Segmentation Fault occurs. The output is:

terminate called after throwing an instance of 'int'
Segmentation fault (core dumped)

The stack trace is:

Program terminated with signal 11, Segmentation fault.
#0  0x10059f08 in __cxa_begin_catch (exc_obj_in=<incomplete type>)
    at ../../../../../gcc-4.0.3/libstdc++-v3/libsupc++/eh_catch.cc:80
80      ../../../../../gcc-4.0.3/libstdc++-v3/libsupc++/eh_catch.cc: A
file or directory in the path name does not exist..
        in ../../../../../gcc-4.0.3/libstdc++-v3/libsupc++/eh_catch.cc

Is it possible to create an executable that throws exceptions and
statically links in the gcc libraries without Segmentation faults?

Cheers,
Jon


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2006-06-22 17:30 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2006-06-22 17:30 Segmentation faults with static linking Jon.Barks

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).