From ec5fed758cbe1552c4716f2ac615d09a68905bca Mon Sep 17 00:00:00 2001 From: Konstantin Belousov Date: Mon, 30 Nov 2020 17:00:36 +0000 Subject: [PATCH] Ensure that threading library is initialized in pthread_mutex_init(). We need at least thr_malloc ready. The situation is possible e.g. in case of libthr being listed in DT_NEEDED before some of its consumers. Reported and tested by: lev Sponsored by: The FreeBSD Foundation MFC after: 1 week --- lib/libthr/thread/thr_mutex.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/lib/libthr/thread/thr_mutex.c b/lib/libthr/thread/thr_mutex.c index 57984ef6d0e6..303386db7fe7 100644 --- a/lib/libthr/thread/thr_mutex.c +++ b/lib/libthr/thread/thr_mutex.c @@ -384,6 +384,8 @@ __Tthr_mutex_init(pthread_mutex_t * __restrict mutex, struct pthread_mutex *pmtx; int ret; + _thr_check_init(); + if (mutex_attr != NULL) { ret = mutex_check_attr(*mutex_attr); if (ret != 0)