From: Nicholas Clark Date: Sun, 13 Nov 2005 11:44:30 +0000 (+0000) Subject: Integrate: X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=678f9f8e69283f64dcdcd30e3fe602110d10a5a6;p=p5sagit%2Fp5-mst-13.2.git Integrate: [ 26108] BEGIN blocks should start a new stack, as they can be called as a side effect of "regular" Perl API calls within subroutines that have already cached the current stack's address. If they don't, any stack extension during the call may move the stack, rendering that cached value invalid without the cachee realising. (For example, PP code calling gv_fetchpv() which triggers a load of Errno.pm) p4raw-link: @26108 on //depot/maint-5.8/perl: 5480675bc37b4a804a56a749cdedc70e27a270eb p4raw-id: //depot/perl@26110 p4raw-integrated: from //depot/maint-5.8/perl@26107 'merge in' op.c (@26097..) --- diff --git a/op.c b/op.c index 03ca56e..a3dee91 100644 --- a/op.c +++ b/op.c @@ -4538,8 +4538,10 @@ Perl_newATTRSUB(pTHX_ I32 floor, OP *o, OP *proto, OP *attrs, OP *block) goto done; if (strEQ(s, "BEGIN") && !PL_error_count) { + dSP; const I32 oldscope = PL_scopestack_ix; ENTER; + PUSHSTACKi(PERLSI_REQUIRE); SAVECOPFILE(&PL_compiling); SAVECOPLINE(&PL_compiling); @@ -4552,6 +4554,7 @@ Perl_newATTRSUB(pTHX_ I32 floor, OP *o, OP *proto, OP *attrs, OP *block) PL_curcop = &PL_compiling; PL_compiling.op_private = (U8)(PL_hints & HINT_PRIVATE_MASK); + POPSTACK; LEAVE; } else if (strEQ(s, "END") && !PL_error_count) {