From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 3123 invoked by alias); 3 Jan 2003 15:30:49 -0000 Mailing-List: contact pthreads-win32-help@sources.redhat.com; run by ezmlm Precedence: bulk List-Subscribe: List-Archive: List-Post: List-Help: , Sender: pthreads-win32-owner@sources.redhat.com Received: (qmail 3114 invoked from network); 3 Jan 2003 15:30:44 -0000 Received: from unknown (HELO mailout09.sul.t-online.com) (194.25.134.84) by 209.249.29.67 with SMTP; 3 Jan 2003 15:30:44 -0000 Received: from fwd07.sul.t-online.de by mailout09.sul.t-online.com with smtp id 18UTmI-0000MF-0D; Fri, 03 Jan 2003 16:30:30 +0100 Received: from pseudo.t-online.de (520069358420-0001@[217.225.139.223]) by fwd07.sul.t-online.com with esmtp id 18UTm1-0Lr70yC; Fri, 3 Jan 2003 16:30:13 +0100 Message-Id: <5.1.0.14.0.20030103155101.00c88690@pop.t-online.de> Date: Fri, 03 Jan 2003 15:30:00 -0000 To: pthreads-win32@sources.redhat.com From: beckmann.bremen@t-online.de (Thomas Beckmann) Subject: pthread_key_create destructor Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii"; format=flowed X-Sender: 520069358420-0001@t-dialin.net X-SW-Source: 2003/txt/msg00000.txt.bz2 Hi, I have a problem with pthread_key_create (). I'm using the latest(2002-11-4) pre-build pthreadVC.dll on Windows XP with MSVC++ 6.0. I wrote the following example to explain the problem: #include #include #include pthread_key_t key; void destructor (void *ptr) { printf ((char*)ptr); free (ptr); } int main (int argc, char *argv[]) { char *ptr; pthread_key_create (&key, &destructor); if ((ptr = pthread_getspecific(key)) == NULL) { ptr = strdup ("test\n"); pthread_setspecific (key, ptr); } return 0; } I think, this is a valid example, and it works fine as a release version but the debug version crashes inside the destructor() function . The address of ptr inside destructor() is the same as inside main() but when having a look at the memory pointed to by ptr, it is initialized to zero at the end of main but unspecified inside of destructor(). It seems, that the address of ptr is already outside the applications address space or somehow else invalid, so the destructor is called too late. Thanks for any help, Thomas Beckmann