[Bug 189] ash behaves strangely on CTRL-C (does not exit but fills process table)
bugzilla at busybox.net
bugzilla at busybox.net
Thu Mar 19 18:44:17 UTC 2009
https://bugs.busybox.net/show_bug.cgi?id=189
--- Comment #14 from Denys Vlasenko <vda.linux at googlemail.com> 2009-03-19 18:44:16 UTC ---
Ok, I took deeper look into this mess. I went back to original bug, and used
this script, let's call it bug1.sh:
trap "echo USR1" USR1
while true; do
echo Sleeping
sleep 5
done
Was running it under ash from 1.13.3 (reproduced ^C bug easily) and was adding
TRACE(()) machinery until I saw where the bug is.
There are two of them. First one is that in evaltree, when we check for EXSIG
exception:
int err = setjmp(jmploc.loc);
if (err) {
/* if it was a signal, check for trap handlers */
if (exception == EXSIG)
goto out;
we do go to dotrap() via "goto out", BUT WE DONT RESTORE suppressint counter!
It easily may be left too big.
New, more verbose trace, looks like this:
1237485605 [4865] pending s:2 i:1(supp:1) wait returns pid=-1, status=0x0,
errno=4(Interrupted system call)
1237485605 [4865] pending s:2 i:1(supp:1) raising exception 5
1237485605 [4865] pending s:2 i:1(supp:2) exception 5 in evaltree
1237485605 [4865] pending s:0 i:1(supp:2) dotrap entered
1237485605 [4865] pending s:0 i:1(supp:2) sig 2 is active, will run handler
'(null)'
1237485605 [4865] pending s:0 i:1(supp:2) dotrap returns 0
1237485605 [4865] pending s:0 i:1(supp:2) pid 4865, evaltree(0x12e3350: 0, 2)
called
1237485605 [4865] pending s:0 i:1(supp:2) evalcommand(0x12e3350, 2) called
1237485605 [4865] pending s:0 i:1(supp:2) evalcommand arg: true
1237485605 [4865] pending s:0 i:1(supp:2) dowait(0x1) called
See "supp:2"? That's suppressint which is stuck one too big, and ^C won't be
handled.
I added SAVE_INT/RESTORE_INT around entire evaltree, and then I see
(with enev more debug):
1237486866 [7240] pending s:2 i:1(supp:1) wait returns pid=-1, status=0x0,
errno=4(Interrupted system call)
1237486866 [7240] pending s:2 i:1(supp:1) raising exception 5 on line 3821
1237486866 [7240] pending s:2 i:1(supp:2) exception 5 (EXSIG) in evaltree,
err=1
1237486866 [7240] pending s:0 i:1(supp:2) dotrap entered
1237486866 [7240] pending s:0 i:1(supp:2) sig 2 is active, will run handler
'(null)'
1237486866 [7240] pending s:0 i:1(supp:2) dotrap returns 0
1237486866 [7240] pending s:0 i:1(supp:0) raising interrupt on line 8082
1237486866 [7240] pending s:0 i:0(supp:0) raising exception 5 on line 336
1237486866 [7240] pending s:0 i:0(supp:1) exception 5 (EXSIG) in evaltree,
err=1
1237486866 [7240] pending s:0 i:0(supp:0) leaving evaltree
1237486866 [7240] pending s:0 i:0(supp:0) evaltree(0x8a0350: 0, 2) called
1237486866 [7240] pending s:0 i:0(supp:0) evalcommand(0x8a0350, 2) called
1237486866 [7240] pending s:0 i:0(supp:0) evalcommand arg: true
1237486866 [7240] pending s:0 i:0(supp:0) dowait(0x1) called
"raising interrupt on line 8082" is ok, but it doesn't work.
Well, *this* is our old bug, already fixed - gotsig[SIGINT - 1] was erroneously
cleared by dotrap()
I am adding SAVE_INT/RESTORE_INT fix to ash hotfix:
http://busybox.net/downloads/fixes-1.13.3/busybox-1.13.3-ash.patch
If it still fails for you, can you produce a DEBUG 2 trace of bug1.sh under
SIGUSR1+SIGINT test?
--
Configure bugmail: https://bugs.busybox.net/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are on the CC list for the bug.
More information about the busybox-cvs
mailing list