Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 12 Sep 2008 06:51:10 -0700
From:      Jeremy Chadwick <koitsu@FreeBSD.org>
To:        Barry Andrews <titanandrews@gmail.com>
Cc:        Daniel Eischen <deischen@freebsd.org>, freebsd-hackers@freebsd.org
Subject:   Re: loading multi threaded library into executable enabled for single thread
Message-ID:  <20080912135110.GA57637@icarus.home.lan>
In-Reply-To: <eda4c18b0809120626u48fbe5e2pdf7147d71d1f8def@mail.gmail.com>
References:  <eda4c18b0809111206t6438f87dmb8fab0db939c9980@mail.gmail.com> <Pine.GSO.4.64.0809111620340.13959@sea.ntplx.net> <48CA555A.4050104@gmail.com> <20080912131045.GA56923@icarus.home.lan> <eda4c18b0809120626u48fbe5e2pdf7147d71d1f8def@mail.gmail.com>

next in thread | previous in thread | raw e-mail | index | archive | help
On Fri, Sep 12, 2008 at 09:26:37AM -0400, Barry Andrews wrote:
> I don't understand. If it was not broken, then why did it change in later
> FreeBSD versions?

I should be more explicit: the threading library and implementations
have changed over time.  There was libc_r, then there was libthr, then
there was libkse.  This is what we call "evolution".  :-)

http://www.unobvious.com/bsd/freebsd-threads.html
http://kerneltrap.org/node/624
http://www.freebsd.org/kse/

The gcc -pthread flag is still there on present-day FreeBSD (6 through
HEAD), and *should* be used.  You can choose not to use it but you must
ensure during linktime that you explicitly link to -lpthread.

> On Fri, Sep 12, 2008 at 9:10 AM, Jeremy Chadwick <koitsu@freebsd.org> wrote:
> 
> > On Fri, Sep 12, 2008 at 07:41:14AM -0400, Barry Andrews wrote:
> > > Do you know if this is documented in Release Notes or Known Issues or
> > > somewhere?
> >
> > Why would it be an "issue"?  gcc -pthread and libpthread linking is
> > documented pretty much everywhere on the web.  There isn't anything
> > broken about it, it's how it's done on older FreeBSD.
> >
> > Note that all of this has significantly changed in later FreeBSD
> > versions, and that the 5.x series was deprecated a very long time ago.
> >
> > >> On Thu, 11 Sep 2008, Barry Andrews wrote:
> > >>
> > >>> Hi All,
> > >>>
> > >>> I have a multi-threaded library that is linked against libpthread.
> > >>> When I
> > >>> load this lib into a tclsh process on FreeBSD, I get this error,
> > >>> "Recurse on
> > >>> private mutex". and crash. I understand that I can have this issue
> > >>> when the
> > >>> executable is not linked against libpthread but one of the loaded
> > >>> libs is.
> > >>> Basically, it thinks it's in single threaded mode.
> > >>
> > >> This must be an older version of FreeBSD.  I think you must
> > >> link your application (tclsh or whatever) against libpthread
> > >> in order for this to work.  The libc functions won't get properly
> > >> overloaded by their equivalents in libpthread unless you do
> > >> this.
> >
> > --
> > | Jeremy Chadwick                                jdc at parodius.com |
> > | Parodius Networking                       http://www.parodius.com/ |
> > | UNIX Systems Administrator                  Mountain View, CA, USA |
> > | Making life hard for others since 1977.              PGP: 4BD6C0CB |
> >
> >
> _______________________________________________
> freebsd-hackers@freebsd.org mailing list
> http://lists.freebsd.org/mailman/listinfo/freebsd-hackers
> To unsubscribe, send any mail to "freebsd-hackers-unsubscribe@freebsd.org"

-- 
| Jeremy Chadwick                                jdc at parodius.com |
| Parodius Networking                       http://www.parodius.com/ |
| UNIX Systems Administrator                  Mountain View, CA, USA |
| Making life hard for others since 1977.              PGP: 4BD6C0CB |




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20080912135110.GA57637>