commit a381049bf683de48ae2db810af33a088e020cc7d
Author: Petr Písař <ppi...@redhat.com>
Date:   Wed Apr 10 15:37:36 2013 +0200

    Fix dead lock in PerlIO after fork from thread

 ...106212-Add-PL_perlio_mutex-to-atfork_lock.patch |   48 ++++++++++++++++++++
 perl.spec                                          |    6 +++
 2 files changed, 54 insertions(+), 0 deletions(-)
---
diff --git a/perl-5.17.9-106212-Add-PL_perlio_mutex-to-atfork_lock.patch 
b/perl-5.17.9-106212-Add-PL_perlio_mutex-to-atfork_lock.patch
new file mode 100644
index 0000000..9e3fa34
--- /dev/null
+++ b/perl-5.17.9-106212-Add-PL_perlio_mutex-to-atfork_lock.patch
@@ -0,0 +1,48 @@
+From 4da80956418bbe1fdc23cad0b1cbb24cd7b87609 Mon Sep 17 00:00:00 2001
+From: =?UTF-8?q?Patrik=20H=C3=A4gglund?= <patrik.h.haggl...@ericsson.com>
+Date: Sat, 2 Feb 2013 20:21:05 +0100
+Subject: [PATCH] PATCH [perl #106212] Add PL_perlio_mutex to
+ atfork_lock/unlock
+
+Using threads + fork() on Linux, and IO operations in the threads, the
+PL_perlio_mutex may be left in a locked state at the call of fork(),
+potentially leading to deadlock in the child process at subsequent IO
+operations. (Threads are pre-empted and not continued in the child
+process after the fork.)
+
+Therefore, ensure that the PL_perlio_mutex is unlocked in the child
+process, right after fork(), by using atfork_lock/unlock.
+
+(The RT text gives ways to reproduce the problem, but are not easily
+added to Perl's test suite)
+---
+ util.c | 6 ++++++
+ 1 file changed, 6 insertions(+)
+
+diff --git a/util.c b/util.c
+index 5c695b8..75381f1 100644
+--- a/util.c
++++ b/util.c
+@@ -2798,6 +2798,9 @@ Perl_atfork_lock(void)
+    dVAR;
+ #if defined(USE_ITHREADS)
+     /* locks must be held in locking order (if any) */
++#  ifdef USE_PERLIO
++    MUTEX_LOCK(&PL_perlio_mutex);
++#  endif
+ #  ifdef MYMALLOC
+     MUTEX_LOCK(&PL_malloc_mutex);
+ #  endif
+@@ -2812,6 +2815,9 @@ Perl_atfork_unlock(void)
+     dVAR;
+ #if defined(USE_ITHREADS)
+     /* locks must be released in same order as in atfork_lock() */
++#  ifdef USE_PERLIO
++    MUTEX_UNLOCK(&PL_perlio_mutex);
++#  endif
+ #  ifdef MYMALLOC
+     MUTEX_UNLOCK(&PL_malloc_mutex);
+ #  endif
+-- 
+1.8.1.4
+
diff --git a/perl.spec b/perl.spec
index 4c22355..92f6c64 100644
--- a/perl.spec
+++ b/perl.spec
@@ -119,6 +119,9 @@ Patch22:        
perl-5.16.3-Don-t-leak-deleted-iterator-when-tying-hash.patch
 Patch23:        perl-5.16.3-Free-iterator-when-freeing-tied-hash.patch
 Patch24:        perl-5.16.3-Don-t-leak-if-hh-copying-dies.patch
 
+# Fix dead lock in PerlIO after fork from thread, rhbz#947444, RT#106212
+Patch25:        perl-5.17.9-106212-Add-PL_perlio_mutex-to-atfork_lock.patch
+
 # Update some of the bundled modules
 # see http://fedoraproject.org/wiki/Perl/perl.spec for instructions
 
@@ -1830,6 +1833,7 @@ tarball from perl.org.
 %patch22 -p1
 %patch23 -p1
 %patch24 -p1
+%patch25 -p1
 
 #copy the example script
 cp -a %{SOURCE5} .
@@ -2044,6 +2048,7 @@ pushd %{build_archlib}/CORE/
     'Fedora Patch22: Fix leaking tied hashes (RT#107000) [1]' \
     'Fedora Patch23: Fix leaking tied hashes (RT#107000) [2]' \
     'Fedora Patch24: Fix leaking tied hashes (RT#107000) [3]' \
+    'Fedora Patch25: Fix dead lock in PerlIO after fork from thread 
(RT106212)' \
     %{nil}
 
 rm patchlevel.bak
@@ -3485,6 +3490,7 @@ sed \
 %changelog
 * Wed Apr 10 2013 Petr Pisar <ppi...@redhat.com> - 4:5.16.3-270
 - Fix leaking tied hashes (bug #859910)
+- Fix dead lock in PerlIO after fork from thread (bug #947444)
 
 * Tue Apr 09 2013 Petr Pisar <ppi...@redhat.com> - 4:5.16.3-269
 - Sub-package Sys-Syslog (bug #950057)
--
Fedora Extras Perl SIG
http://www.fedoraproject.org/wiki/Extras/SIGs/Perl
perl-devel mailing list
perl-de...@lists.fedoraproject.org
https://admin.fedoraproject.org/mailman/listinfo/perl-devel

Reply via email to