[gnutls-devel] GnuTLS | fix threading bug in libgnutls (#1044)

Development of GNU's TLS library gnutls-devel at lists.gnutls.org
Sat Jun 27 20:35:10 CEST 2020



James Bottomley created an issue: https://gitlab.com/gnutls/gnutls/-/issues/1044



`On a very recent openSUSE build, libgnutls is getting built without
libpthread.  This caused a thread related error when trying to load a
pkcs11 module that uses threading.  The reason is rather convoluted:
glibc actually controls all the pthread_ function calls, but it returns
success without doing anything unless -lpthread is in the link list. 
What's happening is that gnutls_system_mutex_init() is being called on
_gnutls_pkcs11_mutex before library pthreading is initialized, so the
pthread_mutex_init ends up being a nop.  Then, when the pkcs11 module
is loaded, pthreads get initialized and the call to pthread_mutex_lock
is real, but errors out on the uninitialized mutex.

The problem seems to be that nothing in the gnulib macros gnutls relies
on for threading support detection actually sets LTLIBPTHREAD, they
only set LIBPTHREAD.  The fix is to use LIBPTHREAD in lib/Makefile.in

Signed-off-by: James Bottomley <James.Bottomley at HansenPartnership.com>

---

diff --git a/lib/Makefile.am b/lib/Makefile.am
index f55f298f7b..cee7906765 100644
--- a/lib/Makefile.am
+++ b/lib/Makefile.am
@@ -168,7 +168,7 @@ libgnutls_la_LIBADD += accelerated/libaccelerated.la
 endif
 
 if !WINDOWS
-thirdparty_libadd += $(LTLIBPTHREAD)
+thirdparty_libadd += $(LIBPTHREAD)
 endif
 
 if NEEDS_LIBRT[tmp.txt](/uploads/f9b3a3cae0774bfda19680f1ba38ecc6/tmp.txt)`

-- 
Reply to this email directly or view it on GitLab: https://gitlab.com/gnutls/gnutls/-/issues/1044
You're receiving this email because of your account on gitlab.com.


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.gnupg.org/pipermail/gnutls-devel/attachments/20200627/1436fa33/attachment.html>


More information about the Gnutls-devel mailing list