Blame SOURCES/perl-5.16.3-Remove-PERL_ASYNC_CHECK-from-Perl_leave_scope.patch

9572a7
From 13716dc35cd0869b98bd30cebbdeb8d48ab07a8b Mon Sep 17 00:00:00 2001
9572a7
From: Nicholas Clark <nick@ccl4.org>
9572a7
Date: Sat, 14 Apr 2012 15:51:33 +0200
9572a7
Subject: [PATCH] Remove PERL_ASYNC_CHECK() from Perl_leave_scope().
9572a7
9572a7
PERL_ASYNC_CHECK() was added to Perl_leave_scope() as part of commit
9572a7
f410a2119920dd04, which moved signal dispatch from the runloop to
9572a7
control flow ops, to mitigate nearly all of the speed cost of safe
9572a7
signals.
9572a7
9572a7
The assumption was that scope exit was a safe place to dispatch signals.
9572a7
However, this is not true, as parts of the regex engine call
9572a7
leave_scope(), the regex engine stores some state in per-interpreter
9572a7
variables, and code called within signal handlers can change these
9572a7
values.
9572a7
9572a7
Hence remove the call to PERL_ASYNC_CHECK() from Perl_leave_scope(), and
9572a7
add it explicitly in the various OPs which were relying on their call to
9572a7
leave_scope() to dispatch any pending signals. Also add a
9572a7
PERL_ASYNC_CHECK() to the exit of the runloop, which ensures signals
9572a7
still dispatch from S_sortcv() and S_sortcv_stacked(), as well as
9572a7
addressing one of the concerns in the commit message of
9572a7
f410a2119920dd04:
9572a7
9572a7
    Subtle bugs might remain - there might be constructions that enter
9572a7
    the runloop (where signals used to be dispatched) but don't contain
9572a7
    any PERL_ASYNC_CHECK() calls themselves.
9572a7
9572a7
Finally, move the PERL_ASYNC_CHECK(); added by that commit to pp_goto to
9572a7
the end of the function, to be consistent with the positioning of all
9572a7
other PERL_ASYNC_CHECK() calls - at the beginning or end of OP
9572a7
functions, hence just before the return to or just after the call from
9572a7
the runloop, and hence effectively at the same point as the previous
9572a7
location of PERL_ASYNC_CHECK() in the runloop.
9572a7
---
9572a7
 dump.c   |  1 +
9572a7
 pp_ctl.c | 11 ++++++++++-
9572a7
 run.c    |  1 +
9572a7
 scope.c  |  2 --
9572a7
 4 files changed, 12 insertions(+), 3 deletions(-)
9572a7
9572a7
diff --git a/dump.c b/dump.c
9572a7
index b238ee0..d770a65 100644
9572a7
--- a/dump.c
9572a7
+++ b/dump.c
9572a7
@@ -2118,6 +2118,7 @@ Perl_runops_debug(pTHX)
9572a7
 	}
9572a7
     } while ((PL_op = PL_op->op_ppaddr(aTHX)));
9572a7
     DEBUG_l(Perl_deb(aTHX_ "leaving RUNOPS level\n"));
9572a7
+    PERL_ASYNC_CHECK();
9572a7
 
9572a7
     TAINT_NOT;
9572a7
     return 0;
9572a7
diff --git a/pp_ctl.c b/pp_ctl.c
9572a7
index fd92efa..6206a25 100644
9572a7
--- a/pp_ctl.c
9572a7
+++ b/pp_ctl.c
9572a7
@@ -377,6 +377,7 @@ PP(pp_substcont)
9572a7
 	    TAINT_NOT;
9572a7
 	    LEAVE_SCOPE(cx->sb_oldsave);
9572a7
 	    POPSUBST(cx);
9572a7
+	    PERL_ASYNC_CHECK();
9572a7
 	    RETURNOP(pm->op_next);
9572a7
 	    /* NOTREACHED */
9572a7
 	}
9572a7
@@ -2732,6 +2733,7 @@ PP(pp_next)
9572a7
     if (PL_scopestack_ix < inner)
9572a7
 	leave_scope(PL_scopestack[PL_scopestack_ix]);
9572a7
     PL_curcop = cx->blk_oldcop;
9572a7
+    PERL_ASYNC_CHECK();
9572a7
     return (cx)->blk_loop.my_op->op_nextop;
9572a7
 }
9572a7
 
9572a7
@@ -2774,6 +2776,7 @@ PP(pp_redo)
9572a7
     LEAVE_SCOPE(oldsave);
9572a7
     FREETMPS;
9572a7
     PL_curcop = cx->blk_oldcop;
9572a7
+    PERL_ASYNC_CHECK();
9572a7
     return redo_op;
9572a7
 }
9572a7
 
9572a7
@@ -2978,6 +2981,7 @@ PP(pp_goto)
9572a7
 		PUTBACK;
9572a7
 		(void)(*CvXSUB(cv))(aTHX_ cv);
9572a7
 		LEAVE;
9572a7
+		PERL_ASYNC_CHECK();
9572a7
 		return retop;
9572a7
 	    }
9572a7
 	    else {
9572a7
@@ -3049,6 +3053,7 @@ PP(pp_goto)
9572a7
 			}
9572a7
 		    }
9572a7
 		}
9572a7
+		PERL_ASYNC_CHECK();
9572a7
 		RETURNOP(CvSTART(cv));
9572a7
 	    }
9572a7
 	}
9572a7
@@ -3209,6 +3214,7 @@ PP(pp_goto)
9572a7
 	PL_do_undump = FALSE;
9572a7
     }
9572a7
 
9572a7
+    PERL_ASYNC_CHECK();
9572a7
     RETURNOP(retop);
9572a7
 }
9572a7
 
9572a7
@@ -5129,10 +5135,13 @@ PP(pp_leavewhen)
9572a7
 	    leave_scope(PL_scopestack[PL_scopestack_ix]);
9572a7
 	PL_curcop = cx->blk_oldcop;
9572a7
 
9572a7
+	PERL_ASYNC_CHECK();
9572a7
 	return cx->blk_loop.my_op->op_nextop;
9572a7
     }
9572a7
-    else
9572a7
+    else {
9572a7
+	PERL_ASYNC_CHECK();
9572a7
 	RETURNOP(cx->blk_givwhen.leave_op);
9572a7
+    }
9572a7
 }
9572a7
 
9572a7
 PP(pp_continue)
9572a7
diff --git a/run.c b/run.c
9572a7
index 7c1d0aa..774852d 100644
9572a7
--- a/run.c
9572a7
+++ b/run.c
9572a7
@@ -40,6 +40,7 @@ Perl_runops_standard(pTHX)
9572a7
     register OP *op = PL_op;
9572a7
     while ((PL_op = op = op->op_ppaddr(aTHX))) {
9572a7
     }
9572a7
+    PERL_ASYNC_CHECK();
9572a7
 
9572a7
     TAINT_NOT;
9572a7
     return 0;
9572a7
diff --git a/scope.c b/scope.c
9572a7
index ffd0552..121d1f7 100644
9572a7
--- a/scope.c
9572a7
+++ b/scope.c
9572a7
@@ -1168,8 +1168,6 @@ Perl_leave_scope(pTHX_ I32 base)
9572a7
     }
9572a7
 
9572a7
     PL_tainted = was;
9572a7
-
9572a7
-    PERL_ASYNC_CHECK();
9572a7
 }
9572a7
 
9572a7
 void
9572a7
-- 
9572a7
1.8.1.4
9572a7