From owner-freebsd-hackers@FreeBSD.ORG Sun Jan 7 15:54:54 2007 Return-Path: X-Original-To: freebsd-hackers@freebsd.org Delivered-To: freebsd-hackers@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id 62D9816A40F for ; Sun, 7 Jan 2007 15:54:54 +0000 (UTC) (envelope-from deischen@freebsd.org) Received: from mail.ntplx.net (mail.ntplx.net [204.213.176.10]) by mx1.freebsd.org (Postfix) with ESMTP id 24B0313C44C for ; Sun, 7 Jan 2007 15:54:54 +0000 (UTC) (envelope-from deischen@freebsd.org) Received: from sea.ntplx.net (sea.ntplx.net [204.213.176.11]) by mail.ntplx.net (8.13.8/8.13.8/NETPLEX) with ESMTP id l07Fif2v015063; Sun, 7 Jan 2007 10:44:42 -0500 (EST) Date: Sun, 7 Jan 2007 10:44:41 -0500 (EST) From: Daniel Eischen X-X-Sender: eischen@sea.ntplx.net To: Daniel Molina Wegener In-Reply-To: <200701070834.21711.dmw@unete.cl> Message-ID: References: <200701070834.21711.dmw@unete.cl> MIME-Version: 1.0 Content-Type: MULTIPART/MIXED; BOUNDARY="-559023410-959030623-1168184681=:5044" X-Greylist: Message whitelisted by DRAC access database, not delayed by milter-greylist-3.0 (mail.ntplx.net [204.213.176.10]); Sun, 07 Jan 2007 10:44:42 -0500 (EST) X-Virus-Scanned: by AMaViS and Clam AntiVirus (mail.ntplx.net) Cc: FreeBSD Hackers Subject: Re: strange pthread keys behavior X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list Reply-To: Daniel Eischen List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 07 Jan 2007 15:54:54 -0000 This message is in MIME format. The first part should be readable text, while the remaining parts are likely unreadable without MIME-aware tools. ---559023410-959030623-1168184681=:5044 Content-Type: TEXT/PLAIN; charset=iso-8859-1; format=flowed Content-Transfer-Encoding: QUOTED-PRINTABLE On Sun, 7 Jan 2007, Daniel Molina Wegener wrote: > Hello, > > I'm coding with pthreads, but the behavior of pthread_key_delete > is strange. When I use pthread_key_delete, and I do not wait for the > automatic deallocation of thread specific data, I receive a strange > warning: > > Thread 8053800 has exited with leftover thread-specific data after \ > 4 destructor iterations > > =BFIs this a mistake in the code or a standard warning in FreeBSD > pthreads? Yes, it looks like a buggy program... > The code bellow can be compiled with and do not use the > pthread_key_delete routine: See the POSIX spec with regard to pthread_key_create(): http://www.opengroup.org/onlinepubs/009695399/functions/pthread_key_crea= te.html You may have to create an account (free) in order to view it. Also look at pthread_key_delete(). I think the problem is that you are calling pthread_key_delete() from the thread that is creating the key and before the thread has exited (when the thread-specific key data is destroyed). You have invalidated the key by deleting it, so when the thread exits, it can't call the destructor and it iterates PTHREAD_KEY_MAX times trying to deallocate the key data. That is where the error message is generated. --=20 DE ---559023410-959030623-1168184681=:5044--