fix deadlock in trap, backported from devel branch

Signed-off-by: Roman Rakus <rrakus@redhat.com>
This commit is contained in:
Roman Rakus 2013-06-27 10:03:57 +02:00
parent f6ffed783f
commit 185aa1593d
2 changed files with 68 additions and 1 deletions

60
bash-4.2-trap.patch Normal file
View File

@ -0,0 +1,60 @@
commit 41d203e21f94c1b8bfc457606ee633c22da3cf04
Author: Chet Ramey <chet.ramey@case.edu>
Date: Wed Jun 12 09:29:51 2013 -0400
commit bash-20130523 snapshot
diff --git a/trap.c b/trap.c
index 1e11d1f..da59b26 100644
--- a/trap.c
+++ b/trap.c
@@ -286,6 +286,9 @@ run_pending_traps ()
if (catch_flag == 0) /* simple optimization */
return;
+ if (running_trap > 0)
+ return; /* no recursive trap invocations */
+
catch_flag = trapped_signal_received = 0;
/* Preserve $? when running trap. */
@@ -304,6 +307,8 @@ run_pending_traps ()
BLOCK_SIGNAL (sig, set, oset);
+ running_trap = sig + 1;
+
if (sig == SIGINT)
{
run_interrupt_trap ();
@@ -324,6 +329,7 @@ run_pending_traps ()
{
/* This can happen when run_pending_traps is called while
running a SIGCHLD trap handler. */
+ running_trap = 0;
UNBLOCK_SIGNAL (oset);
continue; /* XXX */
}
@@ -359,7 +365,14 @@ run_pending_traps ()
save_subst_varlist = subst_assign_varlist;
subst_assign_varlist = 0;
+#if defined (JOB_CONTROL)
+ save_pipeline (1); /* XXX only provides one save level */
+#endif
evalstring (savestring (trap_list[sig]), "trap", SEVAL_NONINT|SEVAL_NOHIST|SEVAL_RESETLINE);
+#if defined (JOB_CONTROL)
+ restore_pipeline (1);
+#endif
+
restore_token_state (token_state);
free (token_state);
@@ -367,6 +380,7 @@ run_pending_traps ()
}
pending_traps[sig] = 0;
+ running_trap = 0;
UNBLOCK_SIGNAL (oset);
}

View File

@ -6,7 +6,7 @@
Version: %{baseversion}%{patchleveltag}
Name: bash
Summary: The GNU Bourne Again shell
Release: 1%{?dist}
Release: 2%{?dist}
Group: System Environment/Shells
License: GPLv3+
Url: http://www.gnu.org/software/bash
@ -115,6 +115,9 @@ Patch125: bash-4.2-size_type.patch
# 903833, Fix missing close(), fixes fd leaks
Patch126: bash-4.2-missing_closes.patch
# fix deadlock in trap, backported from devel branch
Patch127: bash-4.2-trap.patch
BuildRequires: texinfo bison
BuildRequires: ncurses-devel
BuildRequires: autoconf, gettext
@ -408,6 +411,10 @@ end
#%doc doc/*.ps doc/*.0 doc/*.html doc/article.txt
%changelog
* Thu Jun 27 2013 Roman Rakus <rrakus@redhat.com> - 4.2.45-2
- Fixed a bug that caused trap handlers to be executed recursively,
corrupting internal data structures.
* Mon Mar 11 2013 Roman Rakus <rrakus@redhat.com> - 4.2.45-1
- Patchlevel 45