From a5d38b1de7baa8bffa09ffa68984da779201af3f Mon Sep 17 00:00:00 2001 From: Martijn Dekker Date: Sun, 27 Sep 2020 06:46:52 +0200 Subject: [PATCH] add missing function crash test (re: 6193c6a3) Of course I was wrong to say the bug had nothing to do with functions; traps in ksh functions are local, are handled the same way as traps that are local to virtual subshells, and had the same crashing bug. So this adds a test for that as well. --- src/cmd/ksh93/tests/functions.sh | 17 +++++++++++++++++ src/cmd/ksh93/tests/subshell.sh | 1 - 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/src/cmd/ksh93/tests/functions.sh b/src/cmd/ksh93/tests/functions.sh index 535985f1576a..721ba58abee2 100755 --- a/src/cmd/ksh93/tests/functions.sh +++ b/src/cmd/ksh93/tests/functions.sh @@ -1306,5 +1306,22 @@ actual=$( [[ $actual == "$expect" ]] || err_exit "wrong exit status from function invoked by command substitution" \ "(expected $(printf %q "$expect"), got $(printf %q "$actual"))" +# ====== +# https://bugzilla.redhat.com/1117404 + +cat >$tmp/crash_rhbz1117404.ksh <<-'EOF' + trap "" HUP # trigger part 1: signal ignored in main shell + function ksh_fun + { + trap ": foo" HUP # trigger part 2: any local trap (empty or not) on same signal in ksh function + } + for((i=0; i<2500; i++)) + do ksh_fun + done +EOF +got=$( { "$SHELL" "$tmp/crash_rhbz1117404.ksh"; } 2>&1) +((!(e = $?))) || err_exit 'crash while handling function-local trap' \ + "(got status $e$( ((e>128)) && print -n / && kill -l "$e"), $(printf %q "$got"))" + # ====== exit $((Errors<125?Errors:125)) diff --git a/src/cmd/ksh93/tests/subshell.sh b/src/cmd/ksh93/tests/subshell.sh index 56d4115d39cb..d24122aa194e 100755 --- a/src/cmd/ksh93/tests/subshell.sh +++ b/src/cmd/ksh93/tests/subshell.sh @@ -852,7 +852,6 @@ actual=`get_value` cat >$tmp/crash_rhbz1117404.ksh <<-'EOF' trap "" HUP # trigger part 1: signal ignored in main shell - i=0 for((i=0; i<2500; i++)) do (trap ": foo" HUP) # trigger part 2: any trap (empty or not) on same signal in subshell done