Remove PERL_ASYNC_CHECK() from Perl_leave_scope().
authorNicholas Clark <nick@ccl4.org>
Sat, 14 Apr 2012 13:51:33 +0000 (15:51 +0200)
committerKarl Williamson <public@khwilliamson.com>
Thu, 9 May 2013 14:49:41 +0000 (08:49 -0600)
commit47c9d59fcd27684d94480b806b8b6e001aac91cc
tree0d1d8053a6c41f471d366c40344ff28f072313e4
parentd16360cf46a05f65d649c1fe5a38802db2c250d4
Remove PERL_ASYNC_CHECK() from Perl_leave_scope().

PERL_ASYNC_CHECK() was added to Perl_leave_scope() as part of commit
f410a2119920dd04, which moved signal dispatch from the runloop to
control flow ops, to mitigate nearly all of the speed cost of safe
signals.

The assumption was that scope exit was a safe place to dispatch signals.
However, this is not true, as parts of the regex engine call
leave_scope(), the regex engine stores some state in per-interpreter
variables, and code called within signal handlers can change these
values.

Hence remove the call to PERL_ASYNC_CHECK() from Perl_leave_scope(), and
add it explicitly in the various OPs which were relying on their call to
leave_scope() to dispatch any pending signals. Also add a
PERL_ASYNC_CHECK() to the exit of the runloop, which ensures signals
still dispatch from S_sortcv() and S_sortcv_stacked(), as well as
addressing one of the concerns in the commit message of
f410a2119920dd04:

    Subtle bugs might remain - there might be constructions that enter
    the runloop (where signals used to be dispatched) but don't contain
    any PERL_ASYNC_CHECK() calls themselves.

Finally, move the PERL_ASYNC_CHECK(); added by that commit to pp_goto to
the end of the function, to be consistent with the positioning of all
other PERL_ASYNC_CHECK() calls - at the beginning or end of OP
functions, hence just before the return to or just after the call from
the runloop, and hence effectively at the same point as the previous
location of PERL_ASYNC_CHECK() in the runloop.
dump.c
pp_ctl.c
run.c
scope.c