commit
84d061d5a31c9c773e29e1e2b1ffe8cb9557bc58 wrongly moved the
access to the global next_key outside of the scope of the lock. the
error manifested as spurious failure to find an available key slot
under concurrent calls to pthread_key_create, since the stopping
condition could be met after only a small number of slots were
examined.
int __pthread_key_create(pthread_key_t *k, void (*dtor)(void *))
{
- pthread_key_t j = next_key;
pthread_t self = __pthread_self();
/* This can only happen in the main thread before
if (!dtor) dtor = nodtor;
__pthread_rwlock_wrlock(&key_lock);
+ pthread_key_t j = next_key;
do {
if (!keys[j]) {
keys[next_key = *k = j] = dtor;