Re: static linking of pthread crashes with segfault

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



"Klaus Rudolph" <lts-rudolph@xxxxxx> 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 of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux