Skip to content

Commit

Permalink
add missing function crash test (re: 6193c6a)
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
McDutchie committed Sep 27, 2020
1 parent 6193c6a commit a5d38b1
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 1 deletion.
17 changes: 17 additions & 0 deletions src/cmd/ksh93/tests/functions.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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))
1 change: 0 additions & 1 deletion src/cmd/ksh93/tests/subshell.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit a5d38b1

Please sign in to comment.