From owner-freebsd-threads@FreeBSD.ORG Fri Sep 14 04:43:49 2007 Return-Path: Delivered-To: freebsd-threads@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id D438316A420; Fri, 14 Sep 2007 04:43:49 +0000 (UTC) (envelope-from lavajoe@gentoo.org) Received: from shadow.wildlava.net (shadow.wildlava.net [67.40.138.81]) by mx1.freebsd.org (Postfix) with ESMTP id A39D613C469; Fri, 14 Sep 2007 04:43:49 +0000 (UTC) (envelope-from lavajoe@gentoo.org) Received: from [10.1.2.160] (pawnee.wildlava.net [67.40.138.85]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by shadow.wildlava.net (Postfix) with ESMTP id DAB738F431; Thu, 13 Sep 2007 22:43:48 -0600 (MDT) Message-ID: <46EA0365.6070800@gentoo.org> Date: Thu, 13 Sep 2007 21:43:33 -0600 From: Joe Peterson User-Agent: Thunderbird 2.0.0.6 (X11/20070816) MIME-Version: 1.0 To: David Xu References: <46E9CBC8.3060906@gentoo.org> <46E9E867.7030909@freebsd.org> In-Reply-To: <46E9E867.7030909@freebsd.org> Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Cc: freebsd-threads@freebsd.org Subject: Re: Segfault when mapping libpthread -> libthr X-BeenThere: freebsd-threads@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Threading on FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 14 Sep 2007 04:43:49 -0000 David Xu wrote: > Joe Peterson wrote: >> I am a developer on the Gentoo/FreeBSD project. For those who don't >> know, this is basically porting the gentoo tools, package installer, >> init stuff, etc. to FreeBSD (kernel and userland). I have been >> investigating a rather challenging crash in libthr with 6.2. We have >> libpthread and libc_r mapped to libthr (as I understand this is the >> default for 7.0). I doubt, however, that this issue is gentoo-related, >> since the system is essentially FreeBSD, but I cannot be 100% sure, of >> course. >> >> In particular, ImageMagick's "mogrify" utility is segfaulting. I have >> traced this down to the fact that _cur_thread() returns a different >> address after many mutex locks in pthread (using the libthr library). >> This causes the mutex linked list in the thread to have zero pointers >> for first/last, and the crash results. I have verified with a >> ImageMagick developer that mogrfiy is using only one thread, so this >> should never happen. >> >> Another clue is that the curthread address seems to change sometime >> shortly before __error (in libthr/sys/thr_error.c) gets called. >> >> I now am not sure how to debug this further. The address returned by >> _get_curthread() is close, but slightly higher (by typically 0x100) than >> the original thread's address. >> >> I can reproduce the problem faithfully on two of my systems, so if any >> of this rings a bell, or if you have any suggestions for things to try >> on my end, I'd be extremely appreciative! >> >> -Joe > you may try revision 1.3 of > http://www.freebsd.org/cgi/cvsweb.cgi/src/lib/libthr/sys/thr_error.c > to see if the problem goes away. Nope, still same result. The call to __error() doesn't happen until quite a few _get_curthread() calls happen and many mutex's get locked/unlocked, so I was not optimistic this would fix it. -Joe