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 it was initialized with, then I suppose I may not call pthread_mutexattr_destroy(&attr) before using the mutex.