from "man pthread_mutex_unlock":
If the mutex type is PTHREAD_MUTEX_ERRORCHECK, then error checking
shall be provided. If a thread attempts to relock a mutex that it has
already locked, an error shall be returned. If a thread attempts to
unlock a mutex that it has not locked or a mutex which is unlocked, an
error shall be returned.
from "man pthread_ mutex_unlock" : MUTEX_ERRORCHEC K, then error checking
If the mutex type is PTHREAD_
shall be provided. If a thread attempts to relock a mutex that it has
already locked, an error shall be returned. If a thread attempts to
unlock a mutex that it has not locked or a mutex which is unlocked, an
error shall be returned.
That might be something to try.