# New Ticket Created by power...@sky.net.ua # Please include the string: [perl #20920] # in the subject line of all future correspondence about this issue. # <URL: http://rt.perl.org/rt2/Ticket/Display.html?id=20920 >
This is a bug report for perl from power...@sky.net.ua, generated with the help of perlbug 1.34 running under perl v5.8.0.
----------------------------------------------------------------- [Please enter your report here]
powerman:~$ time perl -e ' use Time::HiRes qw(alarm); $SIG{ALRM} = sub { 1 for 1..100000 }; alarm(0.01, 0.01); sleep(1); ' Segmentation fault real 0m33.523s user 0m33.520s sys 0m0.000s
Hardcoded constant 100000 should be large enough: loop 1..100000 should take more than 0.01 sec, so new signal arrives before old signal processed.
The workaround is to reinstall alarm after previous signal handler finished:
powerman:~$ time perl -e ' use Time::HiRes qw(alarm); $SIG{ALRM} = sub { 1 for 1..100000; alarm(0.01) }; alarm(0.01); sleep(1) for 1..100; ' real 0m2.041s user 0m1.020s sys 0m0.000s
This bug seems to be related to "Safe Signals" introduced in 5.8.0 because 5.6.1 don't die with 'Segmentation fault', it just hang (and it should hang!).
[Please do not change anything below this line] ----------------------------------------------------------------- --- Flags: category=core severity=critical --- Site configuration information for perl v5.8.0:
Configured by root at Tue Feb 11 17:22:15 EET 2003.
> # New Ticket Created by power...@sky.net.ua > # Please include the string: [perl #20920] > # in the subject line of all future correspondence about this issue. > # <URL: http://rt.perl.org/rt2/Ticket/Display.html?id=20920 >
> This is a bug report for perl from power...@sky.net.ua, > generated with the help of perlbug 1.34 running under perl v5.8.0.
> ----------------------------------------------------------------- > [Please enter your report here]
> powerman:~$ time perl -e ' > use Time::HiRes qw(alarm); > $SIG{ALRM} = sub { 1 for 1..100000 }; > alarm(0.01, 0.01); > sleep(1); > ' > Segmentation fault > real 0m33.523s > user 0m33.520s > sys 0m0.000s
> Hardcoded constant 100000 should be large enough: loop 1..100000 should take > more than 0.01 sec, so new signal arrives before old signal processed.
> The workaround is to reinstall alarm after previous signal handler finished:
> powerman:~$ time perl -e ' > use Time::HiRes qw(alarm); > $SIG{ALRM} = sub { 1 for 1..100000; alarm(0.01) }; > alarm(0.01); > sleep(1) for 1..100; > ' > real 0m2.041s > user 0m1.020s > sys 0m0.000s
> This bug seems to be related to "Safe Signals" introduced in 5.8.0 because > 5.6.1 don't die with 'Segmentation fault', it just hang (and it should hang!).
The safe signals implementation has the side effect that signals are not blocked anymore if the same signal is raised while the signal handler is running. This is normally done automatically by the OS and should now be manually set using sigprocmask (see patch below).
--- bleedperl/mg.c Sun Feb 2 18:59:19 2003 +++ bleedperl2/mg.c Fri Feb 14 08:47:04 2003 @@ -1159,8 +1159,24 @@ Perl_despatch_signals(pTHX) PL_sig_pending = 0; for (sig = 1; sig < SIG_SIZE; sig++) { if (PL_psig_pend[sig]) { +#define PERL_BLOCK_SIGNALS +#if defined(HAS_SIGPROCMASK) && defined(PERL_BLOCK_SIGNALS) + /* From sigaction(2) (FreeBSD man page): + * | Signal routines normally execute with the signal that + * | caused their invocation blocked, but other signals may + * | yet occur. + * Emulate this behavior. + */ + sigset_t set; + sigemptyset(&set); + sigaddset(&set,sig); PL_psig_pend[sig] = 0; + sigprocmask(SIG_BLOCK, &set, NULL); +#endif /* HAS_SIGPROCMASK */ (*PL_sighandlerp)(sig); +#if defined(HAS_SIGPROCMASK) && defined(PERL_BLOCK_SIGNALS) + sigprocmask(SIG_UNBLOCK, &set, NULL); +#endif /* HAS_SIGPROCMASK */ } } }
> [Please do not change anything below this line] > ----------------------------------------------------------------- > --- > Flags: > category=core > severity=critical > --- > Site configuration information for perl v5.8.0:
> Configured by root at Tue Feb 11 17:22:15 EET 2003.
Does this SIG_UNBLOCK code get called if (*PL_sighandlerp)(sig) die()s?
-- "So, who beat the clueless idiot today?" "Well, we flipped for it, but when Kuno landed, he wasn't in any shape to fight." "Next time, try flipping a *coin.*"
> The safe signals implementation has the side effect that signals are > not blocked anymore if the same signal is raised while the signal > handler is running. This is normally done automatically by the OS and > should now be manually set using sigprocmask (see patch below).
> --- bleedperl/mg.c Sun Feb 2 18:59:19 2003 > +++ bleedperl2/mg.c Fri Feb 14 08:47:04 2003 > @@ -1159,8 +1159,24 @@ Perl_despatch_signals(pTHX)
Thanks, applied as change #18765.
-- Jarkko Hietaniemi <j...@iki.fi> http://www.iki.fi/jhi/ "There is this special biologist word we use for 'stable'. It is 'dead'." -- Jack Cohen