From 8b5a10d4a5ea15405fe049325803c9d54d51d998 Mon Sep 17 00:00:00 2001 From: Nils Philippsen Date: Feb 13 2015 16:43:52 +0000 Subject: fix failing (crashing) concurrency stress test --- diff --git a/.gitignore b/.gitignore index b77d904..eee20b6 100644 --- a/.gitignore +++ b/.gitignore @@ -3,3 +3,4 @@ babl-0.1.2.tar.bz2 /babl-0.1.6.tar.bz2 /babl-0.1.10.tar.bz2 /babl-0.1.12.tar.bz2 +/babl-0.1.12-2-autofoo.patch.xz diff --git a/babl-0.1.12-concurrency-stresstest.patch b/babl-0.1.12-concurrency-stresstest.patch new file mode 100644 index 0000000..19efa95 --- /dev/null +++ b/babl-0.1.12-concurrency-stresstest.patch @@ -0,0 +1,183 @@ +From 290193ffde359536a3c92fd28e49d0001299b1aa Mon Sep 17 00:00:00 2001 +From: Nils Philippsen +Date: Fri, 13 Feb 2015 17:29:39 +0100 +Subject: [PATCH] patch: concurrency-stresstest + +Squashed commit of the following: + +commit 0df44e20b530e02faee169150d282950b78868b2 +Author: Nils Philippsen +Date: Fri Feb 13 13:29:13 2015 +0100 + + Remove workaround for non-recursive mutexes. + + This workaround caused concurrency-stress-test to fail occasionally. + Meanwhile BablMutex wraps pthread mutexes in a way that they are + initialized as recursive. + + This partially reverts commit 9d2aa7d13ac421935de1e87301c48af50b0ceb59. + + (cherry picked from commit 81ef6f201164c81876028a506b00b52976041741) + +commit 90634a3998bf59e5fba77520f27b0016c601592a +Author: Nils Philippsen +Date: Fri Feb 13 13:24:52 2015 +0100 + + Make BablMutex recursive on all platforms. + + Win32 Critical Sections are recursive locks, initialize pthread mutexes + as recursive as well. + + (cherry picked from commit 6bf8a87b83f56e26d947acd5fab78370c4902a26) +--- + babl.pc.in | 3 ++- + babl/Makefile.am | 2 +- + babl/babl-fish-path.c | 6 ++---- + babl/babl-mutex.c | 7 ++++++- + configure.ac | 3 +++ + extensions/Makefile.am | 3 ++- + tests/Makefile.am | 2 +- + tools/Makefile.am | 4 ++-- + 8 files changed, 19 insertions(+), 11 deletions(-) + +diff --git a/babl.pc.in b/babl.pc.in +index 76b5e69..3f2049f 100644 +--- a/babl.pc.in ++++ b/babl.pc.in +@@ -7,4 +7,5 @@ Name: babl + Description: Dynamic, any to any, pixel format conversion library + Version: @BABL_REAL_VERSION@ + Cflags: -I${includedir}/@PACKAGE_NAME@-@BABL_API_VERSION@ +-Libs: -L${libdir} -l@PACKAGE_NAME@-@BABL_API_VERSION@ @MATH_LIB@ ++Libs: -L${libdir} -l@PACKAGE_NAME@-@BABL_API_VERSION@ ++Libs.private: @MATH_LIB@ @THREAD_LIB@ +diff --git a/babl/Makefile.am b/babl/Makefile.am +index 4f59447..6827faa 100644 +--- a/babl/Makefile.am ++++ b/babl/Makefile.am +@@ -86,7 +86,7 @@ libbabl_@BABL_API_VERSION@_la_LIBADD=\ + @LTLIBOBJS@ + + libbabl_@BABL_API_VERSION@_la_LDFLAGS= \ +- ${no_undefined} $(MATH_LIB) \ ++ ${no_undefined} $(MATH_LIB) $(THREAD_LIB) \ + -version-info $(BABL_LIBRARY_VERSION) + + EXTRA_DIST = babl-ref-pixels.inc +diff --git a/babl/babl-fish-path.c b/babl/babl-fish-path.c +index 5dc0601..bf9c520 100644 +--- a/babl/babl-fish-path.c ++++ b/babl/babl-fish-path.c +@@ -300,8 +300,7 @@ babl_fish_path (const Babl *source, + pc.fish_path = babl; + pc.to_format = (Babl *) destination; + +- if (babl_in_fish_path <= 0) +- babl_mutex_lock (babl_format_mutex); ++ babl_mutex_lock (babl_format_mutex); + /* we hold a global lock whilerunning get_conversion_path since + * it depends on keeping the various format.visited members in + * a consistent state, this code path is not performance critical +@@ -312,8 +311,7 @@ babl_fish_path (const Babl *source, + get_conversion_path (&pc, (Babl *) source, 0, max_path_length ()); + + babl_in_fish_path--; +- if (babl_in_fish_path <= 0) +- babl_mutex_unlock (babl_format_mutex); ++ babl_mutex_unlock (babl_format_mutex); + babl_free (pc.current_path); + } + +diff --git a/babl/babl-mutex.c b/babl/babl-mutex.c +index 3f82cc5..eacd372 100644 +--- a/babl/babl-mutex.c ++++ b/babl/babl-mutex.c +@@ -30,7 +30,12 @@ babl_mutex_new (void) + #ifdef _WIN32 + InitializeCriticalSection (mutex); + #else +- pthread_mutex_init (mutex, NULL); ++ pthread_mutexattr_t mutexattr; ++ ++ pthread_mutexattr_init (&mutexattr); ++ pthread_mutexattr_settype (&mutexattr, PTHREAD_MUTEX_RECURSIVE); ++ pthread_mutex_init (mutex, &mutexattr); ++ pthread_mutexattr_destroy (&mutexattr); + #endif + return mutex; + } +diff --git a/configure.ac b/configure.ac +index b07d4d5..3ed6404 100644 +--- a/configure.ac ++++ b/configure.ac +@@ -254,6 +254,7 @@ AC_MSG_RESULT([$platform_win32]) + AM_CONDITIONAL(PLATFORM_WIN32, test "$platform_win32" = "yes") + + MATH_LIB=-lm ++THREAD_LIB=-lpthread + AC_MSG_CHECKING([for native Win32]) + case "$target_or_host" in + *-*-mingw*) +@@ -261,6 +262,7 @@ case "$target_or_host" in + PATH_SEP=';' + DIR_SEP='\\' + MATH_LIB= ++ THREAD_LIB= + ;; + *) + os_win32=no +@@ -272,6 +274,7 @@ AC_MSG_RESULT([$os_win32]) + AC_SUBST(PATH_SEP) + AC_SUBST(DIR_SEP) + AC_SUBST(MATH_LIB) ++AC_SUBST(THREAD_LIB) + + AM_CONDITIONAL(OS_WIN32, test "$os_win32" = "yes") + AM_CONDITIONAL(OS_UNIX, test "$os_win32" != "yes") +diff --git a/extensions/Makefile.am b/extensions/Makefile.am +index 3954739..4a3fb8a 100644 +--- a/extensions/Makefile.am ++++ b/extensions/Makefile.am +@@ -53,7 +53,8 @@ ycbcr_la_SOURCES = ycbcr.c + float_la_SOURCES = float.c + fast_float_la_SOURCES = fast-float.c + +-LIBS = $(top_builddir)/babl/libbabl-@BABL_API_VERSION@.la $(MATH_LIB) ++LIBS = $(top_builddir)/babl/libbabl-@BABL_API_VERSION@.la $(MATH_LIB) \ ++ $(THREAD_LIB) + + sse2_float_la_CFLAGS = $(SSE2_EXTRA_CFLAGS) + sse2_int8_la_CFLAGS = $(SSE2_EXTRA_CFLAGS) +diff --git a/tests/Makefile.am b/tests/Makefile.am +index 2733a28..6e282af 100644 +--- a/tests/Makefile.am ++++ b/tests/Makefile.am +@@ -35,7 +35,7 @@ AM_LDFLAGS = -pthread + endif + + LDADD = $(top_builddir)/babl/libbabl-@BABL_API_VERSION@.la \ +- $(MATH_LIB) ++ $(MATH_LIB) $(THREAD_LIB) + + EXTRA_DIST=common.inc + +diff --git a/tools/Makefile.am b/tools/Makefile.am +index f67a66e..ad54455 100644 +--- a/tools/Makefile.am ++++ b/tools/Makefile.am +@@ -1,9 +1,9 @@ + AM_CPPFLAGS = -I$(top_srcdir) -I$(top_srcdir)/babl + + LDADD = $(top_builddir)/babl/libbabl-@BABL_API_VERSION@.la \ +- $(MATH_LIB) ++ $(MATH_LIB) $(THREAD_LIB) + + if HAVE_SRANDOM + noinst_PROGRAMS = \ + babl-gen-test-pixels +-endif +\ No newline at end of file ++endif +-- +2.1.0 + diff --git a/babl.spec b/babl.spec index 3f5d5a9..0a5c152 100644 --- a/babl.spec +++ b/babl.spec @@ -12,7 +12,7 @@ Summary: A dynamic, any to any, pixel format conversion library Name: babl Version: 0.1.12 -Release: 1%{?dist} +Release: 2%{?dist} # Compute some version related macros # Ugly hack, you need to get your quoting backslashes/percent signs straight @@ -26,6 +26,13 @@ License: LGPLv3+ and GPLv3+ Group: System Environment/Libraries URL: http://www.gegl.org/babl/ Source0: http://download.gimp.org/pub/babl/%{apiver}/%{name}-%{version}.tar.bz2 +# Fix crashing concurrency stresstest. +# Upstream commits: +# 6bf8a87b83f56e26d947acd5fab78370c4902a26 +# 81ef6f201164c81876028a506b00b52976041741 +Patch0: babl-0.1.12-concurrency-stresstest.patch +# Rebuilt files after changing configure.ac and */Makefile.am above +Patch10: babl-0.1.12-2-autofoo.patch.xz BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n) BuildRequires: librsvg2 @@ -64,6 +71,8 @@ This package contains documentation needed for developing with %{name}. %prep %setup -q +%patch0 -p1 -b .concurrency-stresstest +%patch10 -p1 -b .autofoo %build # use PIC/PIE because babl is likely to deal with data coming from untrusted @@ -124,6 +133,9 @@ rm -rf %{buildroot} %doc %{develdocdir} %changelog +* Fri Feb 13 2015 Nils Philippsen - 0.1.12-2 +- fix failing (crashing) concurrency stress test + * Thu Feb 05 2015 Debarshi Ray - 0.1.12-1 - version 0.1.12 diff --git a/sources b/sources index 3525f36..d7ee553 100644 --- a/sources +++ b/sources @@ -1 +1,2 @@ 50c8d12cdf5b3991590fa6cba16218a0 babl-0.1.12.tar.bz2 +2f79a4c2891303097606c9e597fea04c babl-0.1.12-2-autofoo.patch.xz