Hello. I think, that valgrind can be very useful in tracking balance of pthread mutexes init/destroy. The problem with pthread mutexes is that some realisations may allocate system resourses for every mutex (e.g. on MS Windows), so every mutex must be destroyed. Testing must be done under Linux, if we develop multiplatform application using some variant of pthreads on windows.
I'm going to close this old issue. Whilst I can see that it would be possible to check that uses of int pthread_mutex_destroy(pthread_mutex_t *mutex); int pthread_mutex_init(pthread_mutex_t *restrict mutex, const pthread_mutexattr_t *restrict attr); are matched I don't see how pthread_mutex_t mutex = PTHREAD_MUTEX_INITIALIZER; can be intercepted.