Don't call malloc in signal handler

bugzilla: #800473

Signed-off-by: Roman Rakus <rrakus@redhat.com>
This commit is contained in:
Roman Rakus 2012-04-23 15:47:26 +02:00
parent cdbb6d726b
commit e8e8bf537a
2 changed files with 39 additions and 1 deletions

View File

@ -0,0 +1,30 @@
diff -pruN bash-4.1/jobs.c bash-4.1.patched/jobs.c
--- bash-4.1/jobs.c 2009-11-30 03:42:05.000000000 +0530
+++ bash-4.1.patched/jobs.c 2012-03-06 16:44:15.706595703 +0530
@@ -3037,6 +3037,7 @@ waitchld (wpid, block)
PROCESS *child;
pid_t pid;
int call_set_current, last_stopped_job, job, children_exited, waitpid_flags;
+ int called_from_sighand = sigchld;
static int wcontinued = WCONTINUED; /* run-time fix for glibc problem */
call_set_current = children_exited = 0;
@@ -3161,7 +3162,17 @@ waitchld (wpid, block)
longjmp (wait_intr_buf, 1);
}
- run_sigchld_trap (children_exited);
+ /* Queue up the trap handler if we're called directly from within the
+ signal handler. */
+ if (called_from_sighand)
+ {
+ int i = children_exited;
+ interrupt_immediately = 0;
+ while (i--)
+ trap_handler (SIGCHLD);
+ }
+ else
+ run_sigchld_trap (children_exited);
}
/* We have successfully recorded the useful information about this process

View File

@ -6,7 +6,7 @@
Version: %{baseversion}%{patchleveltag} Version: %{baseversion}%{patchleveltag}
Name: bash Name: bash
Summary: The GNU Bourne Again shell Summary: The GNU Bourne Again shell
Release: 1%{?dist} Release: 2%{?dist}
Group: System Environment/Shells Group: System Environment/Shells
License: GPLv3+ License: GPLv3+
Url: http://www.gnu.org/software/bash Url: http://www.gnu.org/software/bash
@ -79,6 +79,9 @@ Patch120: bash-4.2-rc2-logout.patch
# Static analyzis shows some issues in bash-2.05a-interpreter.patch # Static analyzis shows some issues in bash-2.05a-interpreter.patch
Patch121: bash-4.2-coverity.patch Patch121: bash-4.2-coverity.patch
# Don't call malloc in signal handler
Patch122: bash-4.1-defer-sigchld-trap.patch
BuildRequires: texinfo bison BuildRequires: texinfo bison
BuildRequires: ncurses-devel BuildRequires: ncurses-devel
BuildRequires: autoconf, gettext BuildRequires: autoconf, gettext
@ -154,6 +157,8 @@ This package contains documentation files for %{name}.
%patch119 -p1 -b .broken_pipe %patch119 -p1 -b .broken_pipe
%patch120 -p1 -b .logout %patch120 -p1 -b .logout
%patch121 -p1 -b .coverity %patch121 -p1 -b .coverity
%patch122 -p1 -b .defer_sigchld_trap
echo %{version} > _distribution echo %{version} > _distribution
echo %{release} > _patchlevel echo %{release} > _patchlevel
@ -321,6 +326,9 @@ end
#%doc doc/*.ps doc/*.0 doc/*.html doc/article.txt #%doc doc/*.ps doc/*.0 doc/*.html doc/article.txt
%changelog %changelog
* Mon Apr 23 2012 Roman Rakus <rrakus@redhat.com> - 4.2.24-2
- Don't call malloc in signal handler
* Tue Mar 13 2012 Roman Rakus <rrakus@redhat.com> - 4.2.24-1 * Tue Mar 13 2012 Roman Rakus <rrakus@redhat.com> - 4.2.24-1
- Patchlevel 24 - Patchlevel 24