Index: pthread_mutex.c =================================================================== RCS file: /cvsroot/src/lib/libpthread/pthread_mutex.c,v retrieving revision 1.66 diff -u -r1.66 pthread_mutex.c --- pthread_mutex.c 13 Jan 2020 18:22:56 -0000 1.66 +++ pthread_mutex.c 27 Jan 2020 23:05:29 -0000 @@ -197,6 +197,9 @@ if (__predict_false(__uselibcstub)) return __libc_mutex_lock_stub(ptm); + pthread__error(EINVAL, "Dead mutex", + ptm->ptm_magic != _PT_MUTEX_MAGIC); + self = pthread__self(); val = atomic_cas_ptr(&ptm->ptm_owner, NULL, self); if (__predict_true(val == NULL)) { @@ -214,6 +217,9 @@ pthread_t self; void *val; + pthread__error(EINVAL, "Dead mutex", + ptm->ptm_magic != _PT_MUTEX_MAGIC); + self = pthread__self(); val = atomic_cas_ptr(&ptm->ptm_owner, NULL, self); if (__predict_true(val == NULL)) { @@ -410,6 +416,9 @@ if (__predict_false(__uselibcstub)) return __libc_mutex_trylock_stub(ptm); + pthread__error(EINVAL, "Dead mutex", + ptm->ptm_magic != _PT_MUTEX_MAGIC); + self = pthread__self(); val = atomic_cas_ptr(&ptm->ptm_owner, NULL, self); if (__predict_true(val == NULL)) { @@ -450,6 +459,9 @@ if (__predict_false(__uselibcstub)) return __libc_mutex_unlock_stub(ptm); + pthread__error(EINVAL, "Dead mutex", + ptm->ptm_magic != _PT_MUTEX_MAGIC); + #ifndef PTHREAD__ATOMIC_IS_MEMBAR membar_exit(); #endif @@ -777,6 +789,10 @@ int pthread_mutex_getprioceiling(const pthread_mutex_t *ptm, int *ceil) { + + pthread__error(EINVAL, "Dead mutex", + ptm->ptm_magic != _PT_MUTEX_MAGIC); + *ceil = ptm->ptm_ceiling; return 0; } @@ -786,6 +802,9 @@ { int error; + pthread__error(EINVAL, "Dead mutex", + ptm->ptm_magic != _PT_MUTEX_MAGIC); + error = pthread_mutex_lock(ptm); if (error == 0) { *old_ceil = ptm->ptm_ceiling;