summaryrefslogtreecommitdiffstats
path: root/lib/libthr
diff options
context:
space:
mode:
authorkib <kib@FreeBSD.org>2016-03-21 06:48:11 +0000
committerkib <kib@FreeBSD.org>2016-03-21 06:48:11 +0000
commit7c5b09c965362ccd47a76006eee82e838187e03d (patch)
tree0fd622d9bf093f54c84165f419a66249f864d3f0 /lib/libthr
parent1e240521d214b088e33747a9cf9abbc4baae993f (diff)
downloadFreeBSD-src-7c5b09c965362ccd47a76006eee82e838187e03d.zip
FreeBSD-src-7c5b09c965362ccd47a76006eee82e838187e03d.tar.gz
Provide more information on failing checks in mutex_assert_is_owned()
and mutex_assert_not_owned(). snprintf() use in this context should be safe. Sponsored by: The FreeBSD Foundation
Diffstat (limited to 'lib/libthr')
-rw-r--r--lib/libthr/thread/thr_mutex.c20
1 files changed, 16 insertions, 4 deletions
diff --git a/lib/libthr/thread/thr_mutex.c b/lib/libthr/thread/thr_mutex.c
index 30a8be2..3342c9f 100644
--- a/lib/libthr/thread/thr_mutex.c
+++ b/lib/libthr/thread/thr_mutex.c
@@ -124,8 +124,14 @@ mutex_assert_is_owned(struct pthread_mutex *m)
{
#if defined(_PTHREADS_INVARIANTS)
- if (__predict_false(m->m_qe.tqe_prev == NULL))
- PANIC("mutex is not on list");
+ if (__predict_false(m->m_qe.tqe_prev == NULL)) {
+ char msg[128];
+ snprintf(msg, sizeof(msg),
+ "mutex %p own %#x %#x is not on list %p %p",
+ m, m->m_lock.m_owner, m->m_owner, m->m_qe.tqe_prev,
+ m->m_qe.tqe_next);
+ PANIC(msg);
+ }
#endif
}
@@ -135,8 +141,14 @@ mutex_assert_not_owned(struct pthread_mutex *m)
#if defined(_PTHREADS_INVARIANTS)
if (__predict_false(m->m_qe.tqe_prev != NULL ||
- m->m_qe.tqe_next != NULL))
- PANIC("mutex is on list");
+ m->m_qe.tqe_next != NULL)) {
+ char msg[128];
+ snprintf(msg, sizeof(msg),
+ "mutex %p own %#x %#x is on list %p %p",
+ m, m->m_lock.m_owner, m->m_owner, m->m_qe.tqe_prev,
+ m->m_qe.tqe_next);
+ PANIC(msg);
+ }
#endif
}
OpenPOWER on IntegriCloud