X-Recipient: archive-cygwin AT delorie DOT com X-Spam-Check-By: sourceware.org Date: Tue, 6 Nov 2007 16:30:26 +0100 From: Corinna Vinschen To: cygwin AT cygwin DOT com Subject: Re: why is pthread_key_create failing? Message-ID: <20071106153026.GA1203@calimero.vinschen.de> Reply-To: cygwin AT cygwin DOT com Mail-Followup-To: cygwin AT cygwin DOT com References: <200711061512 DOT 15518 DOT bruno AT clisp DOT org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <200711061512.15518.bruno@clisp.org> User-Agent: Mutt/1.5.16 (2007-06-09) Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: cygwin-owner AT cygwin DOT com Mail-Followup-To: cygwin AT cygwin DOT com Delivered-To: mailing list cygwin AT cygwin DOT com On Nov 6 15:12, Bruno Haible wrote: > Hi, > > In the test program below, pthread_key_create is failing with return value > EBUSY with no good reason. > [...] > The Cygwin version that I'm using is: > $ grep VERSION /usr/include/cygwin/version.h | head -2 > #define CYGWIN_VERSION_DLL_MAJOR 1005 > #define CYGWIN_VERSION_DLL_MINOR 19 Time to update. However, regardless of the version you're using, it's a bug in Cygwin. The pthread_key_create function checks the incoming pthread_key_t pointer for being a valid object already and,if so, bails out with EBUSY. This is arguably wrong, as your example shows, which reuses pthread_key_t slots already used before. Besides, EBUSY isn't defined as a valid error code returned by pthread_key_create. I'll fix that in CVS. For the time being, a working workaround would be: for (i = KEYS_COUNT - 1; i >= 0; i--) { fprintf (stderr, "trying to get key #%d\n", i); fflush (stderr); mykeys[i] = (pthread_key_t) NULL; int err = pthread_key_create (&mykeys[i], free); if (err != 0) { fprintf (stderr, "pthread_key_create -> %d\n", err); abort (); } } Thanks for the testcase! Corinna -- Corinna Vinschen Please, send mails regarding Cygwin to Cygwin Project Co-Leader cygwin AT cygwin DOT com Red Hat -- Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple Problem reports: http://cygwin.com/problems.html Documentation: http://cygwin.com/docs.html FAQ: http://cygwin.com/faq/