-
Notifications
You must be signed in to change notification settings - Fork 3.5k
Potential deadlock, with the unreleased once_init_lock #1183
Copy link
Copy link
Closed
Description
Dear developers:
I found the lock may be unreleased after the function return. Thank you for your checking!
Line 186 in 3d48c75
| pthread_mutex_lock(&once_init_lock); |
int
evthread_use_pthreads_with_flags(int flags)
{
...;
pthread_mutex_lock(&once_init_lock); //HERE
if (once_init == 1) {
pthread_mutex_unlock(&once_init_lock);
return 0;
}
if (pthread_mutexattr_init(&attr_default))
goto error;
/* Set ourselves up to get recursive locks. */
if (pthread_mutexattr_init(&attr_recursive))
goto error;
if (pthread_mutexattr_settype(&attr_recursive, PTHREAD_MUTEX_RECURSIVE))
goto error;
if (flags & EVTHREAD_PTHREAD_PRIO_INHERIT) {
#ifdef EVENT__HAVE_PTHREAD_MUTEXATTR_SETPROTOCOL
/* Set up priority inheritance */
if (pthread_mutexattr_setprotocol(&attr_default, PTHREAD_PRIO_INHERIT))
goto error;
if (pthread_mutexattr_setprotocol(&attr_recursive, PTHREAD_PRIO_INHERIT))
goto error;
#else
goto error;
#endif
}
evthread_set_lock_callbacks(&cbs);
evthread_set_condition_callbacks(&cond_cbs);
evthread_set_id_callback(evthread_posix_get_id);
once_init = 1;
return 0; // the lock onece_init_lock may be unreleased
error:
pthread_mutex_unlock(&once_init_lock);
return -1;
}
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels