All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH libdrm 1/2] configure.ac: error out if pthread-stubs provides a library
@ 2016-10-31 14:59 Emil Velikov
  2016-10-31 14:59 ` [PATCH libdrm 2/2] automake: drop PTHREAD_CFLAGS/LIBS references Emil Velikov
  0 siblings, 1 reply; 2+ messages in thread
From: Emil Velikov @ 2016-10-31 14:59 UTC (permalink / raw)
  To: dri-devel; +Cc: emil.l.velikov

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 --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)
 
-- 
2.10.0

_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply related	[flat|nested] 2+ messages in thread

* [PATCH libdrm 2/2] automake: drop PTHREAD_CFLAGS/LIBS references
  2016-10-31 14:59 [PATCH libdrm 1/2] configure.ac: error out if pthread-stubs provides a library Emil Velikov
@ 2016-10-31 14:59 ` Emil Velikov
  0 siblings, 0 replies; 2+ messages in thread
From: Emil Velikov @ 2016-10-31 14:59 UTC (permalink / raw)
  To: dri-devel; +Cc: emil.l.velikov

From: Emil Velikov <emil.velikov@collabora.com>

As per last commit, we only use the package to check if the runtime is
pthread (stub) aware or not. We don't want to use the contents of the
variables, if any.

Signed-off-by: Emil Velikov <emil.velikov@collabora.com>
---
We can ignore this patch if we consider doing the 
PTHREADSTUBS_{CFLAGS,LIBS} override as mentioned in 1/2


 amdgpu/Makefile.am    | 3 +--
 configure.ac          | 2 --
 exynos/Makefile.am    | 3 +--
 freedreno/Makefile.am | 2 --
 intel/Makefile.am     | 2 --
 nouveau/Makefile.am   | 3 +--
 omap/Makefile.am      | 3 +--
 radeon/Makefile.am    | 3 +--
 tegra/Makefile.am     | 3 +--
 vc4/Makefile.am       | 1 -
 10 files changed, 6 insertions(+), 19 deletions(-)

diff --git a/amdgpu/Makefile.am b/amdgpu/Makefile.am
index cf7bc1b..cf13dba 100644
--- a/amdgpu/Makefile.am
+++ b/amdgpu/Makefile.am
@@ -27,13 +27,12 @@ include Makefile.sources
 AM_CFLAGS = \
 	$(WARN_CFLAGS) \
 	-I$(top_srcdir) \
-	$(PTHREADSTUBS_CFLAGS) \
 	-I$(top_srcdir)/include/drm
 
 libdrm_amdgpu_la_LTLIBRARIES = libdrm_amdgpu.la
 libdrm_amdgpu_ladir = $(libdir)
 libdrm_amdgpu_la_LDFLAGS = -version-number 1:0:0 -no-undefined
-libdrm_amdgpu_la_LIBADD = ../libdrm.la @PTHREADSTUBS_LIBS@
+libdrm_amdgpu_la_LIBADD = ../libdrm.la
 
 libdrm_amdgpu_la_SOURCES = $(LIBDRM_AMDGPU_FILES)
 
diff --git a/configure.ac b/configure.ac
index 097e944..9836102 100644
--- a/configure.ac
+++ b/configure.ac
@@ -65,8 +65,6 @@ 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)
 
 pkgconfigdir=${libdir}/pkgconfig
 AC_SUBST(pkgconfigdir)
diff --git a/exynos/Makefile.am b/exynos/Makefile.am
index f99f898..2305a33 100644
--- a/exynos/Makefile.am
+++ b/exynos/Makefile.am
@@ -1,13 +1,12 @@
 AM_CFLAGS = \
 	$(WARN_CFLAGS) \
 	-I$(top_srcdir) \
-	$(PTHREADSTUBS_CFLAGS) \
 	-I$(top_srcdir)/include/drm
 
 libdrm_exynos_la_LTLIBRARIES = libdrm_exynos.la
 libdrm_exynos_ladir = $(libdir)
 libdrm_exynos_la_LDFLAGS = -version-number 1:0:0 -no-undefined
-libdrm_exynos_la_LIBADD = ../libdrm.la @PTHREADSTUBS_LIBS@
+libdrm_exynos_la_LIBADD = ../libdrm.la
 
 libdrm_exynos_la_SOURCES = \
 	exynos_drm.c \
diff --git a/freedreno/Makefile.am b/freedreno/Makefile.am
index 0771d14..7f07033 100644
--- a/freedreno/Makefile.am
+++ b/freedreno/Makefile.am
@@ -4,7 +4,6 @@ include Makefile.sources
 AM_CFLAGS = \
 	$(WARN_CFLAGS) \
 	-I$(top_srcdir) \
-	$(PTHREADSTUBS_CFLAGS) \
 	-I$(top_srcdir)/include/drm
 
 libdrm_freedreno_la_LTLIBRARIES = libdrm_freedreno.la
@@ -12,7 +11,6 @@ libdrm_freedreno_ladir = $(libdir)
 libdrm_freedreno_la_LDFLAGS = -version-number 1:0:0 -no-undefined
 libdrm_freedreno_la_LIBADD = \
 	../libdrm.la \
-	@PTHREADSTUBS_LIBS@ \
 	@CLOCK_LIB@
 
 libdrm_freedreno_la_SOURCES = $(LIBDRM_FREEDRENO_FILES)
diff --git a/intel/Makefile.am b/intel/Makefile.am
index c52e8c0..8f22e32 100644
--- a/intel/Makefile.am
+++ b/intel/Makefile.am
@@ -27,7 +27,6 @@ include Makefile.sources
 AM_CFLAGS = \
 	$(WARN_CFLAGS) \
 	-I$(top_srcdir) \
-	$(PTHREADSTUBS_CFLAGS) \
 	$(PCIACCESS_CFLAGS) \
 	$(VALGRIND_CFLAGS) \
 	-I$(top_srcdir)/include/drm
@@ -36,7 +35,6 @@ libdrm_intel_la_LTLIBRARIES = libdrm_intel.la
 libdrm_intel_ladir = $(libdir)
 libdrm_intel_la_LDFLAGS = -version-number 1:0:0 -no-undefined
 libdrm_intel_la_LIBADD = ../libdrm.la \
-	@PTHREADSTUBS_LIBS@ \
 	@PCIACCESS_LIBS@ \
 	@CLOCK_LIB@
 
diff --git a/nouveau/Makefile.am b/nouveau/Makefile.am
index 344a844..5ad2ecb 100644
--- a/nouveau/Makefile.am
+++ b/nouveau/Makefile.am
@@ -3,14 +3,13 @@ include Makefile.sources
 AM_CFLAGS = \
 	$(WARN_CFLAGS) \
 	-I$(top_srcdir) \
-	$(PTHREADSTUBS_CFLAGS) \
 	-I$(top_srcdir)/include/drm \
 	-DDEBUG
 
 libdrm_nouveau_la_LTLIBRARIES = libdrm_nouveau.la
 libdrm_nouveau_ladir = $(libdir)
 libdrm_nouveau_la_LDFLAGS = -version-number 2:0:0 -no-undefined
-libdrm_nouveau_la_LIBADD = ../libdrm.la @PTHREADSTUBS_LIBS@
+libdrm_nouveau_la_LIBADD = ../libdrm.la
 
 libdrm_nouveau_la_SOURCES = $(LIBDRM_NOUVEAU_FILES)
 
diff --git a/omap/Makefile.am b/omap/Makefile.am
index 599bb9d..4f157de 100644
--- a/omap/Makefile.am
+++ b/omap/Makefile.am
@@ -1,13 +1,12 @@
 AM_CFLAGS = \
 	$(WARN_CFLAGS) \
 	-I$(top_srcdir) \
-	$(PTHREADSTUBS_CFLAGS) \
 	-I$(top_srcdir)/include/drm
 
 libdrm_omap_la_LTLIBRARIES = libdrm_omap.la
 libdrm_omap_ladir = $(libdir)
 libdrm_omap_la_LDFLAGS = -version-number 1:0:0 -no-undefined
-libdrm_omap_la_LIBADD = ../libdrm.la @PTHREADSTUBS_LIBS@
+libdrm_omap_la_LIBADD = ../libdrm.la
 
 libdrm_omap_la_SOURCES = omap_drm.c
 
diff --git a/radeon/Makefile.am b/radeon/Makefile.am
index e241531..562ef08 100644
--- a/radeon/Makefile.am
+++ b/radeon/Makefile.am
@@ -27,13 +27,12 @@ include Makefile.sources
 AM_CFLAGS = \
 	$(WARN_CFLAGS) \
 	-I$(top_srcdir) \
-	$(PTHREADSTUBS_CFLAGS) \
 	-I$(top_srcdir)/include/drm
 
 libdrm_radeon_la_LTLIBRARIES = libdrm_radeon.la
 libdrm_radeon_ladir = $(libdir)
 libdrm_radeon_la_LDFLAGS = -version-number 1:0:1 -no-undefined
-libdrm_radeon_la_LIBADD = ../libdrm.la @PTHREADSTUBS_LIBS@
+libdrm_radeon_la_LIBADD = ../libdrm.la
 
 libdrm_radeon_la_SOURCES = $(LIBDRM_RADEON_FILES)
 
diff --git a/tegra/Makefile.am b/tegra/Makefile.am
index fb40be5..9cbb40e 100644
--- a/tegra/Makefile.am
+++ b/tegra/Makefile.am
@@ -3,13 +3,12 @@ AM_CPPFLAGS = \
 	-I$(top_srcdir)/include/drm
 
 AM_CFLAGS = \
-	@PTHREADSTUBS_CFLAGS@ \
 	$(WARN_CFLAGS)
 
 libdrm_tegra_ladir = $(libdir)
 libdrm_tegra_la_LTLIBRARIES = libdrm_tegra.la
 libdrm_tegra_la_LDFLAGS = -version-number 0:0:0 -no-undefined
-libdrm_tegra_la_LIBADD = ../libdrm.la @PTHREADSTUBS_LIBS@
+libdrm_tegra_la_LIBADD = ../libdrm.la
 
 libdrm_tegra_la_SOURCES = \
 	private.h \
diff --git a/vc4/Makefile.am b/vc4/Makefile.am
index 7e486b4..c2d3e57 100644
--- a/vc4/Makefile.am
+++ b/vc4/Makefile.am
@@ -24,7 +24,6 @@ include Makefile.sources
 AM_CFLAGS = \
 	$(WARN_CFLAGS) \
 	-I$(top_srcdir) \
-	$(PTHREADSTUBS_CFLAGS) \
 	$(VALGRIND_CFLAGS) \
 	-I$(top_srcdir)/include/drm
 
-- 
2.10.0

_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply related	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2016-10-31 15:10 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-10-31 14:59 [PATCH libdrm 1/2] configure.ac: error out if pthread-stubs provides a library Emil Velikov
2016-10-31 14:59 ` [PATCH libdrm 2/2] automake: drop PTHREAD_CFLAGS/LIBS references Emil Velikov

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.