libpthread problem (segfaults)

Daniel Eischen deischen at freebsd.org
Wed Jun 1 11:45:10 PDT 2005


On Wed, 1 Jun 2005, Benjamin Lutz wrote:
>
> I've found the problem for my own program. I was compiling with -lc. Why
> I started doing that in the first place I can't remember, but removing
> that option fixed above fatal error, and seems to have no negative
> effects (of course, why would it).
>
> So, as a conclusion: gcc apparently produces broken code when -lc is
> specified. I don't know much about how gcc is supposed to work, but that
> might actually be a bug?

No, gcc (the linker really) is doing exactly what you are
telling it.  The linker already brings in libc, you have
to use -nostdlib to prevent it.  You must link to objects
in the correct order.  libpthread, libthr, and libc_r all
provide some functions that are overloaded from libc.
When you link to libc first, you get the libc versions of
those functions instead of the thread versions of them.

> And, something in the 5.3->5.4 upgrade process went wrong which left me
> with a broken libpthread. Can't say what exactly, maybe my system was
> slightly broken to begin with.

libpthread ain't broke; your applications are probably linked
incorrectly.

-- 
DE



More information about the freebsd-stable mailing list