Fix destruction of the robust mutexes.

If robust mutex' owner terminated, causing kernel-assisted state
recovery, and then pthread_mutex_destroy() is executed as the next
action, assert is triggered about mutex still being on the list.
Ignore the mutex linkage in pthread_mutex_destroy() for shared robust
mutexes with dead owner, same as for enqueue_mutex().

Reported by:	avg
Sponsored by:	The FreeBSD Foundation
MFC after:	1 week
This commit is contained in:
Konstantin Belousov 2019-09-23 13:24:31 +00:00
parent 2e6a21bbd8
commit f9bf9282c9
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=352620

View File

@ -474,7 +474,11 @@ _thr_mutex_destroy(pthread_mutex_t *mutex)
if (m == THR_PSHARED_PTR) {
m1 = __thr_pshared_offpage(mutex, 0);
if (m1 != NULL) {
mutex_assert_not_owned(_get_curthread(), m1);
if ((uint32_t)m1->m_lock.m_owner !=
UMUTEX_RB_OWNERDEAD) {
mutex_assert_not_owned(
_get_curthread(), m1);
}
__thr_pshared_destroy(mutex);
}
*mutex = THR_MUTEX_DESTROYED;