This is the mail archive of the gcc-help@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: static linking of pthread crashes with segfault


"Klaus Rudolph" <lts-rudolph@gmx.de> writes:

> I tried to link a pthread application with -static and run into a segfault on x86, same on powerpc.
>
> I tried gcc 4.4.2 (linux/x86) and 4.0.2 for powerpc-unknown-linux-gnu
>
>
>
> For the x86 linux example I got in gdb:
> (gdb) bt
> #0  0x00000000 in ?? ()
> #1  0x08094d49 in __cxa_guard_release ()

This can happen when libstdc++ is configured without __thread support
and you statically link against -lpthread.  The basic bug is that the
libstdc++ configure.ac only uses GCC_CHECK_TLS when configured native.
I thought this had been fixed, but perhaps not.  There is a note on it
here: http://gcc.gnu.org/ml/libstdc++/2008-09/msg00003.html .

Assuming you are using a kernel which supports TLS (2.6.0 or later),
then one fix is to explicitly use --enable-tls when configuring gcc.
Another fix is to use -Wl,--whole-archive -lpthread
-Wl,--no-whole-archive when linking.

Ian


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]