SIGSEGV in insert to global container in shared lib

Matthew Benjamin MBenjamin@comshare.com
Wed Jun 24 11:48:00 GMT 1998


Using EGCS 1.03a compiled on Sparc Solaris 2.6, I've run into problems using
any
standard libraray container at file scope, in a shared library.  (static
linkage??)

First, when I try to use the latest GNU ld to link this code (with -fPIC and
--shared options, of course), ld
dumps core.

I found that the Sun linker will link the code (-G option, of course).  But,
I get a SIGSEGV on the first attempt to insert a value into the container.
(I've tried various template containers, with similar results.)  The same
code works fine if the container is declared in a function, of course.

Eg,  from any program call into foo() in libfile.so as follows: 

// file.cc

#include <set>

set<int> set_of_int;


extern "C" {

foo() {  set_of_int.insert(1); }

}



Matt Benjamin
mbenjamin@comshare.com




More information about the Gcc-bugs mailing list