diff mbox

[libdrm,1/2] configure.ac: error out if pthread-stubs provides a library

Message ID 20161031145951.4009-1-emil.l.velikov@gmail.com (mailing list archive)
State New, archived
Headers show

Commit Message

Emil Velikov Oct. 31, 2016, 2:59 p.m. UTC
From: Emil Velikov <emil.velikov@collabora.com>

If the C runtime doesn't provide the pthread stubs itself, pthread-stubs
will create a library which although it might work is quite fragile and
can cause issues like https://bugs.freedesktop.org/show_bug.cgi?id=98048

Consider the following:

Foo uses pthread-stubs lib (1), then dlopens a module which links
against pthreads (2). After the latter, the pthread-stubs weak symbols
will be overwritten and we'll cause corruption/crashes due to the
mismatch of the API used.

Sometimes the scenario is multiple levels down the dependency chain, be
that 1 and 2 on the same branch or entirely different ones.

Do the robust thing and error out. In practise this shouldn't cause
since any modern runtime provides stub and/or full pthread API in their
libc.so. If that comes to be an issue we can set
PTHREAD_STUBS_{CFLAGS,LIBS} to be the same as the PTHREAD ones.

Signed-off-by: Emil Velikov <emil.velikov@collabora.com>
---
 configure.ac | 3 +++
 1 file changed, 3 insertions(+)
diff mbox

Patch

diff --git a/configure.ac b/configure.ac
index ac6b106..097e944 100644
--- a/configure.ac
+++ b/configure.ac
@@ -62,6 +62,9 @@  LT_INIT([disable-static])
 
 
 PKG_CHECK_MODULES(PTHREADSTUBS, pthread-stubs)
+if test "x$PTHREADSTUBS_LIBS" != x; then
+	AC_MSG_ERROR([pthread-stubs provides a library. This can cause issues - see freedesktop bug #98048.])
+fi
 AC_SUBST(PTHREADSTUBS_CFLAGS)
 AC_SUBST(PTHREADSTUBS_LIBS)