Consider the following code:
pthread_mutexattr_t attr; pthread_mutexattr_init(&attr); pthread_mutexattr_setrobust(&attr, PTHREAD_MUTEX_ROBUST); pthread_mutex_t mut; pthread_mutex_init(&mut, &attr); pthread_mutexattr_destroy(&attr); pthread_mutex_lock(&mut);
Is this code valid?
If the mutex is allowed to contain references to the attribute object with which it was initialized, then I believe that I cannot call pthread_mutexattr_destroy(&attr) before using the mutex.
source share