diff options
author | David Mitchell <davem@iabyn.com> | 2011-03-19 21:49:34 +0000 |
---|---|---|
committer | David Mitchell <davem@iabyn.com> | 2011-03-19 22:03:40 +0000 |
commit | a0d63a7b47ac164b69b3e18cd902f52584a190fc (patch) | |
tree | 8d51d5501660c1b1dfa410cf3518ae7ce5bd88eb /mg.c | |
parent | 9a7f166c9e80e6dce5b942cb7af5fc213e0466d4 (diff) | |
download | perl-a0d63a7b47ac164b69b3e18cd902f52584a190fc.tar.gz |
Perl_sighandler: only inc SS_ix for unsafe signals
Perl_sighandler currently increments the savestack by 5
before running a signal handler, to avoid messing with a
partially completed SS push operation that's been interrupted.
This is irrelevant for safe signals, so make this action conditional on
unsafe signals only.
Diffstat (limited to 'mg.c')
-rw-r--r-- | mg.c | 22 |
1 files changed, 13 insertions, 9 deletions
@@ -3028,12 +3028,14 @@ Perl_sighandler(int sig) exit(sig); } - /* Max number of items pushed there is 3*n or 4. We cannot fix - infinity, so we fix 4 (in fact 5): */ - if (PL_savestack_ix + 15 <= PL_savestack_max) { - flags |= 1; - PL_savestack_ix += 5; /* Protect save in progress. */ - SAVEDESTRUCTOR_X(S_unwind_handler_stack, NULL); + if (PL_signals & PERL_SIGNALS_UNSAFE_FLAG) { + /* Max number of items pushed there is 3*n or 4. We cannot fix + infinity, so we fix 4 (in fact 5): */ + if (PL_savestack_ix + 15 <= PL_savestack_max) { + flags |= 1; + PL_savestack_ix += 5; /* Protect save in progress. */ + SAVEDESTRUCTOR_X(S_unwind_handler_stack, NULL); + } } /* sv_2cv is too complicated, try a simpler variant first: */ if (!SvROK(PL_psig_ptr[sig]) || !(cv = MUTABLE_CV(SvRV(PL_psig_ptr[sig]))) @@ -3057,9 +3059,11 @@ Perl_sighandler(int sig) flags |= 8; SAVEFREESV(sv); - /* make sure our assumption about the size of the SAVEs are correct: - * 3 for SAVEDESTRUCTOR_X, 2 for SAVEFREESV */ - assert(old_ss_ix + 2 + ((flags & 1) ? 3+5 : 0) == PL_savestack_ix); + if (PL_signals & PERL_SIGNALS_UNSAFE_FLAG) { + /* make sure our assumption about the size of the SAVEs are correct: + * 3 for SAVEDESTRUCTOR_X, 2 for SAVEFREESV */ + assert(old_ss_ix + 2 + ((flags & 1) ? 3+5 : 0) == PL_savestack_ix); + } PUSHSTACKi(PERLSI_SIGNAL); PUSHMARK(SP); |