diff --git a/include/asterisk/lock.h b/include/asterisk/lock.h
index 943c7ffe61fdd1cf9aadbd9e3a40f246463c9013..677bfba6d0acd555dff05428a59161ac7129a54b 100644
--- a/include/asterisk/lock.h
+++ b/include/asterisk/lock.h
@@ -428,12 +428,24 @@ int ast_find_lock_info(void *lock_addr, char *filename, size_t filename_size, in
 
 static inline void ast_reentrancy_lock(struct ast_lock_track *lt)
 {
-	pthread_mutex_lock(&lt->reentr_mutex);
+	int res;
+	if ((res = pthread_mutex_lock(&lt->reentr_mutex))) {
+		fprintf(stderr, "ast_reentrancy_lock failed: '%s' (%d)\n", strerror(res), res);
+#if defined(DO_CRASH) || defined(THREAD_CRASH)
+		abort();
+#endif
+	}
 }
 
 static inline void ast_reentrancy_unlock(struct ast_lock_track *lt)
 {
-	pthread_mutex_unlock(&lt->reentr_mutex);
+	int res;
+	if ((res = pthread_mutex_unlock(&lt->reentr_mutex))) {
+		fprintf(stderr, "ast_reentrancy_unlock failed: '%s' (%d)\n", strerror(res), res);
+#if defined(DO_CRASH) || defined(THREAD_CRASH)
+		abort();
+#endif
+	}
 }
 
 static inline void ast_reentrancy_init(struct ast_lock_track **plt)
diff --git a/main/lock.c b/main/lock.c
index eef5d8621a98b8df3c8a031236cf66e749115ba1..3c9fbd4dbd5454304508f96e032475e422a7d54f 100644
--- a/main/lock.c
+++ b/main/lock.c
@@ -51,8 +51,8 @@ int __ast_pthread_mutex_init(int tracking, const char *filename, int lineno, con
 	int res;
 	pthread_mutexattr_t  attr;
 
-	t->track = NULL;
 #ifdef DEBUG_THREADS
+	t->track = NULL;
 #if defined(AST_MUTEX_INIT_W_CONSTRUCTORS) && defined(CAN_COMPARE_MUTEX_TO_INIT_VALUE)
 	if ((t->mutex) != ((pthread_mutex_t) PTHREAD_MUTEX_INITIALIZER)) {
 /*
diff --git a/main/logger.c b/main/logger.c
index e85676857b75dc37e44c85ea3feda2598ce49bf0..03a88c9e80bf5ec97e40a2813680914fb2fc40b5 100644
--- a/main/logger.c
+++ b/main/logger.c
@@ -1211,8 +1211,17 @@ int init_logger(void)
 	/* auto rotate if sig SIGXFSZ comes a-knockin */
 	sigaction(SIGXFSZ, &handle_SIGXFSZ, NULL);
 
-	/* start logger thread */
+	/* Re-initialize the logmsgs mutex.  The recursive mutex can be accessed prior
+ 	 * to Asterisk being forked into the background, which can cause the thread
+ 	 * ID tracked by the underlying pthread mutex to be different than the ID of
+ 	 * the thread that unlocks the mutex.  Since init_logger is called after the
+ 	 * fork, it is safe to initialize the mutex here for future accesses.
+ 	 */
+	ast_mutex_destroy(&logmsgs.lock);
+	ast_mutex_init(&logmsgs.lock);
 	ast_cond_init(&logcond, NULL);
+
+	/* start logger thread */
 	if (ast_pthread_create(&logthread, NULL, logger_thread, NULL) < 0) {
 		ast_cond_destroy(&logcond);
 		return -1;