Skip site navigation (1)Skip section navigation (2)
Date:      Sat, 12 Jul 2003 10:47:50 -0400 (EDT)
From:      Daniel Eischen <eischen@vigrid.com>
To:        Joshua Oreman <oremanj@www.get-linux.org>
Cc:        freebsd-hackers@freebsd.org
Subject:   Re: getpwnam + getpwnam_r + LinuxThreads port = deadlock
Message-ID:  <Pine.GSO.4.10.10307121039090.7013-100000@pcnet5.pcnet.com>
In-Reply-To: <20030712055248.GA23189@webserver.get-linux.org>

next in thread | previous in thread | raw e-mail | index | archive | help
On Fri, 11 Jul 2003, Joshua Oreman wrote:

> Hi -hackers,
> 
> System: FreeBSD 5.0-CURRENT cvsupped around 5.0-RELEASE
> 
> I'm writing an app that links with the LinuxThreads
> (/usr/ports/devel/linuxthreads) and also uses getpwnam(). The problem:
> a deadlock. GDB backtrace:
> 
> Basically: FreeBSD implements getpwnam() as a wrapper around
> getpwnam_r(), as seen in src/lib/libc/gen/getpwent.c:
> 
> So basically, my app calls getpwnam(), which calls the overridden
> getpwnam_r() from LinuxThreads, which calls getpwnam() from libc
> again, and then calls getpwnam_r() from LinuxThreads again, and
> deadlocks trying to recursively lock its own mutex.  Obviously, if
> there was no mutex the stack would leak out the back of my computer
> :-)
> 
> Any ideas here?

Three ideas:

  1) Change the linuxthreads port to not implement getpwname
     in the way that it is (or at all and let it use libc's
     version).

  2) Change libc so that getpwnam and getpwnam_r are weak
     references to _getpwnam and _getpwnam_r respectively
     and have the "_" versions be the real implementation.
     Make all references in libc use _getpwname and
     _getpwnam_r (including the call to _getpwnam_r in
     _getpwnam).

  3) CVSup to the latest 5.x and use libthr or libkse and
     forget linuxthreads.

-- 
Dan Eischen



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?Pine.GSO.4.10.10307121039090.7013-100000>