This is the mail archive of the cygwin mailing list for the Cygwin project.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: why is pthread_key_create failing?

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

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

  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 Vinschen                  Please, send mails regarding Cygwin to
Cygwin Project Co-Leader          cygwin AT cygwin DOT com
Red Hat

Unsubscribe info:
Problem reports:

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]