compiler version: gcc 4.0.0, g++ 4.0.0 Reading specs from /usr/bin/../lib/gcc/powerpc-linux/4.0.0/specs Target: powerpc-linux Configured with: /opt/eldk/build/ppc-2007-01-19/work/usr/src/denx/BUILD/crosstool-0.35/build/gcc-4.0.0-glibc-2.3.5-eldk/powerpc-linux/gcc-4.0.0/configure --target=powerpc-linux --host=i686-host_pc-linux-gnu --prefix=/var/tmp/eldk.HzYZNd/usr/crosstool/gcc-4.0.0-glibc-2.3.5-eldk/powerpc-linux --with-headers=/var/tmp/eldk.HzYZNd/usr/crosstool/gcc-4.0.0-glibc-2.3.5-eldk/powerpc-linux/powerpc-linux/include --with-local-prefix=/var/tmp/eldk.HzYZNd/usr/crosstool/gcc-4.0.0-glibc-2.3.5-eldk/powerpc-linux/powerpc-linux --disable-nls --enable-threads=posix --enable-symvers=gnu --enable-languages=c,c++ --enable-shared --enable-c99 --enable-long-long --enable-__cxa_atexit
Linux version used on target is 2.6.26. I have two shared object files gcc compiled fpp.so and g++ compiled fcc.so. fcc.so is only one file with following code: fccMain.cpp: ----------- #include<iostream> int main() { cout << "Starting fcc.d" <<endl; return 0; } fpp.so has lot of c code. The above two .so's linked with the following command. /usr/bin/6xx-gcc -Wl,-M,-Map,fz.d.map,--cref -o fz.d -lpthread libfcc.so libfpp.so When running the executable(fz.d) on target, once in a while giving segmentation fault before the main. gdb stack dump is given below: ------------------------------ Program received signal SIGSEGV, Segmentation fault. 0x0e03f084 in free () from /lib/libc.so.6 (gdb) where #0 0x0e03f084 in free () from /lib/libc.so.6 #1 0x0df0a70c in std::ctype<char>::ctype () from /usr/lib/libstdc++.so.6 #2 0x0df1006c in std::locale::_Impl::_Impl () from /usr/lib/libstdc++.so.6 #3 0x0df1097c in std::locale::_Impl::_Impl () from /usr/lib/libstdc++.so.6 #4 0x0df0a70c in std::ctype<char>::ctype () from /usr/lib/libstdc++.so.6 #5 0x0e106370 in _IO_2_1_stdin_ () from /lib/libc.so.6 #6 0x0df0a70c in std::ctype<char>::ctype () from /usr/lib/libstdc++.so.6 #7 0x0df10c5c in std::locale::locale () from /usr/lib/libstdc++.so.6 #8 0x0df0e104 in std::ios_base::Init::Init () from /usr/lib/libstdc++.so.6 #9 0x0ffabaa8 in __static_initialization_and_destruction_0 () from /etc/libfcc.so #10 0x0ffabaf8 in global constructors keyed to main () from /etc/libfcc.so #11 0x0ffabd34 in __do_global_ctors_aux () from /etc/libfcc.so #12 0x0df0a70c in std::ctype<char>::ctype () from /usr/lib/libstdc++.so.6 #13 0xbfa15ddc in ?? () #14 0x0df0a70c in std::ctype<char>::ctype () from /usr/lib/libstdc++.so.6 #15 0x4800beb4 in _dl_rtld_di_serinfo () from /lib/ld.so.1 #16 0x48010740 in realloc () from /lib/ld.so.1 Previous frame inner to this frame (corrupt stack?) If i remove the #include<iostream> line(fccMain.cpp) and replace it with either <istream> and <ostream> or with <stdio.h>(printf in place of cout) it is always working without any issue. Global data initialization from libfpp.so is looks happening properly. But libfcc.so global data initialization is failing some times in iostream, while initializing static ios_base::Init __ioinit. I already tried by enabling -fpic, but still the problem is seen. Is it a bug in gcc/g++(4.0.0) ? -Sarveshwara Chary. -- Summary: Segmentation fault(not always) while running binary which has gcc and g++ compiled shared object files Product: gcc Version: 4.0.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: libstdc++ AssignedTo: unassigned at gcc dot gnu dot org ReportedBy: sarveshwarac at india dot tejasnetworks dot com http://gcc.gnu.org/bugzilla/show_bug.cgi?id=43005