changeset 21435:7998dda27211

11002 recursive mutex detection in libfakekernel Reviewed by: Matt Barden <matt.barden@nexenta.com> Reviewed by: Evan Layton <evan.layton@nexenta.com> Approved by: Garrett D'Amore <garrett@damore.org>
author Gordon Ross <gwr@nexenta.com>
date Mon, 22 Feb 2016 14:17:42 -0500
parents a3098b60c2fc
children ecacac58c70f
files usr/src/lib/libfakekernel/common/mapfile-vers usr/src/lib/libfakekernel/common/mutex.c
diffstat 2 files changed, 8 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/usr/src/lib/libfakekernel/common/mapfile-vers	Fri Aug 12 17:30:03 2016 -0400
+++ b/usr/src/lib/libfakekernel/common/mapfile-vers	Mon Feb 22 14:17:42 2016 -0500
@@ -121,9 +121,9 @@
 	kmem_zalloc;
 
 	kmutex_destroy;
-	kmutex_init;
 	kmutex_enter;
 	kmutex_exit;
+	kmutex_init;
 
 	ksema_destroy;
 	ksema_init;
--- a/usr/src/lib/libfakekernel/common/mutex.c	Fri Aug 12 17:30:03 2016 -0400
+++ b/usr/src/lib/libfakekernel/common/mutex.c	Mon Feb 22 14:17:42 2016 -0500
@@ -10,7 +10,7 @@
  */
 
 /*
- * Copyright 2013 Nexenta Systems, Inc.  All rights reserved.
+ * Copyright 2018 Nexenta Systems, Inc.  All rights reserved.
  * Copyright 2017 RackTop Systems.
  */
 
@@ -31,8 +31,9 @@
 
 extern clock_t ddi_get_lbolt(void);
 
+/* See: head/synch.h ERRORCHECKMUTEX */
 static const lwp_mutex_t default_mutex =
-	{{0, 0, 0, {USYNC_THREAD}, _MUTEX_MAGIC},
+	{{0, 0, 0, {USYNC_THREAD|LOCK_ERRORCHECK}, _MUTEX_MAGIC},
 	{{{0, 0, 0, 0, 0, 0, 0, 0}}}, 0};
 
 /* ARGSUSED */
@@ -53,8 +54,11 @@
 void
 kmutex_enter(kmutex_t *mp)
 {
+	kthread_t *t = _curthread();
+
+	VERIFY(mp->m_owner != t);
 	VERIFY(0 == _lwp_mutex_lock(&mp->m_lock));
-	mp->m_owner = _curthread();
+	mp->m_owner = t;
 }
 
 int