From owner-freebsd-threads@FreeBSD.ORG Fri May 20 06:36:03 2005 Return-Path: Delivered-To: freebsd-threads@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id B66FD16A4CE; Fri, 20 May 2005 06:36:03 +0000 (GMT) Received: from mx1.luth.se (mx1.luth.se [130.240.42.11]) by mx1.FreeBSD.org (Postfix) with ESMTP id A3B1343DA8; Fri, 20 May 2005 06:36:01 +0000 (GMT) (envelope-from jnilsson@ludd.ltu.se) Received: from speedy.ludd.ltu.se (speedy.ludd.ltu.se [130.240.16.13]) by mx1.luth.se (8.12.11/8.12.11) with ESMTP id j4K6ZolF002414; Fri, 20 May 2005 08:35:51 +0200 Received: (jnilsson@localhost) by speedy.ludd.ltu.se (8.12.8p1/8.6.11) id j4K4Appv003604; Fri, 20 May 2005 06:10:51 +0200 (CEST) Date: Fri, 20 May 2005 06:10:51 +0200 From: Jens A Nilsson To: Daniel Eischen Message-ID: <20050520041051.GA761@speedy.ludd.ltu.se> References: <200505191138.j4JBcZCM040531@www.freebsd.org> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.4.2.1i Organization: Be-Bop Originalaskkopp X-ltu-MailScanner-Information: Please contact the ISP for more information X-ltu-MailScanner: Found to be clean X-MailScanner-From: jnilsson@ludd.ltu.se cc: freebsd-gnats-submit@freebsd.org cc: Jens Nilsson cc: freebsd-threads@freebsd.org Subject: Re: threads/81258: Thread specific data is sometimes assigned to multiple keys and/or threads X-BeenThere: freebsd-threads@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list Reply-To: jnilsson@ludd.ltu.se List-Id: Threading on FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 20 May 2005 06:36:03 -0000 On Thu, May 19, 2005 at 08:52:23AM -0400, Daniel Eischen wrote: > On Thu, 19 May 2005, Jens Nilsson wrote: > > Thread specific data is sometimes assinged to multiple keys > > and/or threads. In the attached test program two threads getting > > the same tsd for the same key seems to be the most usual. > > > > >How-To-Repeat: > > Run the attached test program a couple of times. One of the > > threads will wait for input, the bug is most likely to show up if > > enter is pressed in about half a second after the thread asked > > for data. > > > > I ran into the bug some time ago while developing a bit more > > complex application that involved a couple of threads all of them > > with TSD and some doing RPC-calls. In that application I had the > > same problem with any of the thread libs libpthread, libthr, and > > libc_r. This test program only seems to be able to repeat the > > problem with libpthread. > > Thread-specific data is destroyed when the thread exits. Your > TSD is allocated using malloc() and destroyed using free(). Your > test program does nothing to ensure that all threads have started > running and have all created/initialized their TSD before the > first thread exits. malloc() is probably reusing a prior > allocation that has been free()'d. > > Thread exiting != Thread being joined. I see, sorry to have bothered you. -- Regards Jens