In perl.git, the branch blead has been updated <http://perl5.git.perl.org/perl.git/commitdiff/31c91b4357905486e81f901ad079da5735bdb7ba?hp=05b4f1ece255de95efcc5a4c74e28b5d04f54401>
- Log ----------------------------------------------------------------- commit 31c91b4357905486e81f901ad079da5735bdb7ba Author: Lubomir Rintel <[email protected]> Date: Thu Jun 25 22:57:46 2009 +0200 Don't enqueue pending signals during global destruction Global destruction is not signal-safe. PL_psig_pend may already be gone when the signal handler is called (with destruct_level > 0). NULL it before freeing it to prevent a race condition. ----------------------------------------------------------------------- Summary of changes: mg.c | 3 ++- perl.c | 7 +++++++ 2 files changed, 9 insertions(+), 1 deletions(-) diff --git a/mg.c b/mg.c index e9e4214..05a5092 100644 --- a/mg.c +++ b/mg.c @@ -1316,13 +1316,14 @@ Perl_csighandler(int sig) #endif (PL_signals & PERL_SIGNALS_UNSAFE_FLAG)) /* Call the perl level handler now-- - * with risk we may be in malloc() etc. */ + * with risk we may be in malloc() or being destructed etc. */ #if defined(HAS_SIGACTION) && defined(SA_SIGINFO) (*PL_sighandlerp)(sig, NULL, NULL); #else (*PL_sighandlerp)(sig); #endif else { + if (!PL_psig_pend) return; /* Set a flag to say this signal is pending, that is awaiting delivery after * the current Perl opcode completes */ PL_psig_pend[sig]++; diff --git a/perl.c b/perl.c index e70bf7e..d9ebaca 100644 --- a/perl.c +++ b/perl.c @@ -1233,6 +1233,13 @@ perl_destruct(pTHXx) PL_psig_ptr = (SV**)NULL; Safefree(PL_psig_pend); PL_psig_pend = (int*)NULL; + { + /* We need to NULL PL_psig_pend first, so that + signal handlers know not to use it */ + int *psig_save = PL_psig_pend; + PL_psig_pend = (int*)NULL; + Safefree(psig_save); + } PL_formfeed = NULL; nuke_stacks(); PL_tainting = FALSE; -- Perl5 Master Repository
