Fix error-checking compiles for mutex
authorRich Salz <rsalz@akamai.com>
Thu, 18 Feb 2021 21:27:08 +0000 (16:27 -0500)
committerPauli <ppzgs1@gmail.com>
Thu, 11 Mar 2021 22:00:18 +0000 (08:00 +1000)
Fixes: #14229
Reviewed-by: Kurt Roeckx <kurt@roeckx.be>
Reviewed-by: Paul Dale <pauli@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/14264)

INSTALL.md
crypto/threads_pthread.c

index 01c360e8d4013198bda8253fd47b6eefd5cc59af..d6ef21d20eb623e2cb1349f10fa75a5d9fc82d0c 100644 (file)
@@ -1666,6 +1666,13 @@ most UNIX/Linux systems), and Windows threads.  No other threading models are
 supported.  If your platform does not provide pthreads or Windows threads then
 you should use `Configure` with the `no-threads` option.
 
+For pthreads, all locks are non-recursive. In addition, in a debug build,
+the mutex attribute `PTHREAD_MUTEX_ERRORCHECK` is used. If this is not
+available on your platform, you might have to add
+`-DOPENSSL_NO_MUTEX_ERRORCHECK` to your `Configure` invocation.
+(On Linux `PTHREAD_MUTEX_ERRORCHECK` is an enum value, so a built-in
+ifdef test cannot be used.)
+
 Notes on shared libraries
 -------------------------
 
index 3004e1bd2ff12c0a4a732f84edc97eeb4991e2dd..e81f3cf1efd2db86afa88355047a7552dcbe2228 100644 (file)
@@ -55,7 +55,7 @@ CRYPTO_RWLOCK *CRYPTO_THREAD_lock_new(void)
      * We don't use recursive mutexes, but try to catch errors if we do.
      */
     pthread_mutexattr_init(&attr);
-#  if defined(NDEBUG) && defined(PTHREAD_MUTEX_ERRORCHECK)
+#  if !defined(NDEBUG) && !defined(OPENSSL_NO_MUTEX_ERRORCHECK)
     pthread_mutexattr_settype(&attr, PTHREAD_MUTEX_ERRORCHECK);
 # else
     pthread_mutexattr_settype(&attr, PTHREAD_MUTEX_NORMAL);