Date: Sun, 7 Jan 2007 10:44:41 -0500 (EST) From: Daniel Eischen <deischen@freebsd.org> To: Daniel Molina Wegener <dmw@unete.cl> Cc: FreeBSD Hackers <freebsd-hackers@freebsd.org> Subject: Re: strange pthread keys behavior Message-ID: <Pine.GSO.4.64.0701071028040.5044@sea.ntplx.net> In-Reply-To: <200701070834.21711.dmw@unete.cl> References: <200701070834.21711.dmw@unete.cl>
next in thread | previous in thread | raw e-mail | index | archive | help
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--
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?Pine.GSO.4.64.0701071028040.5044>