develooper Front page | perl.perl5.porters | Postings from June 2009

[PATCH] [perl #63938] Don't enqueue pending signals during globaldestruction

From:
Lubomir Rintel
Date:
June 26, 2009 07:41
Subject:
[PATCH] [perl #63938] Don't enqueue pending signals during globaldestruction
Message ID:
1245953151.11164.21.camel@trurl
Global destruction is not signal-safe. PL_psig_pend may already
be gone when the signal handler is called (with destruct_level > 0).
---
 mg.c |    3 ++-
 1 files changed, 2 insertions(+), 1 deletions(-)

diff --git a/mg.c b/mg.c
index c94f50e..34dfc23 100644
--- a/mg.c
+++ b/mg.c
@@ -1372,13 +1372,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]++;
-- 
1.5.5.6

-- 
Lubomir Rintel (Good Data)




nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About