Comment 8 for bug 1714254

Revision history for this message
Christian Ehrhardt  (paelzer) wrote :

The post above refers to [1].

In reference to that:

virMutexInit
 55 pthread_mutexattr_t attr;
 56 pthread_mutexattr_init(&attr);
 57 pthread_mutexattr_settype(&attr, PTHREAD_MUTEX_NORMAL);
 58 ret = pthread_mutex_init(&m->lock, &attr);

[...]
 87 void virMutexLock(virMutexPtr m)
 88 {
 89 pthread_mutex_lock(&m->lock);

That is:
PTHREAD_MUTEX_NORMAL
This type of mutex does not detect deadlock. A thread attempting to relock this mutex without first unlocking it will deadlock. Attempting to unlock a mutex locked by a different thread results in undefined behaviour. Attempting to unlock an unlocked mutex results in undefined behaviour.

And from man pthread_mutex_lock:
If the mutex is already locked by the calling thread, the behavior of pthread_mutex_lock depends on the kind of the mutex. If the mutex is of the ``fast'' kind, the calling thread is suspended until the mutex is unlocked, thus effectively causing the calling thread to deadlock.

[1]: http://paste.ubuntu.com/25438609/