From owner-freebsd-hackers@FreeBSD.ORG Mon Jul 14 04:15:23 2003 Return-Path: Delivered-To: freebsd-hackers@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 22CFE37B401; Mon, 14 Jul 2003 04:15:23 -0700 (PDT) Received: from dust.freshx.de (freshx.de [80.190.100.215]) by mx1.FreeBSD.org (Postfix) with ESMTP id 1004F43F3F; Mon, 14 Jul 2003 04:15:22 -0700 (PDT) (envelope-from kai.mosebach@freshx.de) Received: from alpha (p508B3231.dip.t-dialin.net [80.139.50.49]) by dust.freshx.de (Postfix) with ESMTP id 4CB0B15E201; Mon, 14 Jul 2003 13:15:15 +0200 (CEST) From: "Kai Mosebach" To: Date: Mon, 14 Jul 2003 13:15:24 +0200 Message-ID: <000601c349f9$39b69fe0$0100000a@alpha> MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable X-Priority: 3 (Normal) X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook, Build 10.0.4024 In-Reply-To: X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1165 Importance: Normal cc: freebsd-hackers@freebsd.org cc: freebsd-threads@freebsd.org Subject: AW: getpwnam + getpwnam_r + LinuxThreads port = deadlock X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 14 Jul 2003 11:15:23 -0000 > -----Urspr=FCngliche Nachricht----- > Von: owner-freebsd-hackers@freebsd.org [mailto:owner-freebsd- > hackers@freebsd.org] Im Auftrag von Daniel Eischen > Gesendet: Samstag, 12. Juli 2003 21:07 > An: Joshua Oreman > Cc: hackers@freebsd.org > Betreff: Re: getpwnam + getpwnam_r + LinuxThreads port =3D deadlock >=20 > On Sat, 12 Jul 2003, Joshua Oreman wrote: >=20 > > On Sat, Jul 12, 2003 at 10:47:50AM -0400 or thereabouts, Daniel Eischen > wrote: > > > 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). > > > > Probably the easiest way; just include the getpw(nam|uid)_r > > code in #ifndef BSD (or #ifndef __FreeBSD__ if it's only > > a FBSD problem). > > > > > > > > 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). > > > > I think this would still cause the same problem, but not sure. > > > > > > > > 3) CVSup to the latest 5.x and use libthr or libkse and > > > forget linuxthreads. > > I am having the same problems in my sapdb port, as mentioned in another mail. For me its also not this simple to simply switch to kse, because then other kse related problems occur. Wouldnt it be more "clean", to fix the issue in the linuxthreads implementation instead ? (For example many users might use linuxthreads for mysql compilation for example, not knowing what they await ...) Btw : why was this problem not occuring in 5.0-RELEASE ? Cheers Kai