loading multi threaded library into executable enabled for single thread

Brooks Davis brooks at freebsd.org
Thu Sep 11 19:56:05 UTC 2008


On Thu, Sep 11, 2008 at 03:06:35PM -0400, 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.
> 
> I can get around this issue, by doing export LD_PRELOAD=libpthread.so.1,
> however this is a hack at best. Is there any other way to get around this
> issue other than linking tclsh with libpthread ( because that's not an
> option)
> 
> I thought of re-building libpthread with the offending code commented out,
> and that did work, however I ran into other issues, so I think it's not a
> very "safe" option.
> 
> My feeling is that this is a FreeBSD issue because it's not happening on
> other platforms, Linux, Solaris.
> 
> Any suggestions are welcome. Many thanks!

It would be helpful if you could provide:
 - your FreeBSD version
 - the output of "ldd libyourlib.so"
 - the output of "ldd yourprogram"

I wouldn't be supprised to find that the program and library are linked against
different threading libraries.  If so, one of them will need to be relinked or
you will need to use libmap.conf to cause it to use the other one.

-- Brooks
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 187 bytes
Desc: not available
Url : http://lists.freebsd.org/pipermail/freebsd-hackers/attachments/20080911/d9e23228/attachment.pgp


More information about the freebsd-hackers mailing list