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

Re: [perl.git] branch blead, updated. GitLive-blead-1666-gd80618d

Thread Next
From:
Nicholas Clark
Date:
July 25, 2009 13:02
Subject:
Re: [perl.git] branch blead, updated. GitLive-blead-1666-gd80618d
Message ID:
20090725200241.GP6391@plum.flirble.org
On Sat, Jul 25, 2009 at 09:50:39PM +0200, Craig A. Berry wrote:
> In perl.git, the branch blead has been updated
> 
> <http://perl5.git.perl.org/perl.git/commitdiff/d80618d26460a93181dddc9ec53c3fceef864290?hp=b7bfa855cd96849c1ce8b7e9624b69c94149aacc>
> 
> - Log -----------------------------------------------------------------
> commit d80618d26460a93181dddc9ec53c3fceef864290
> Author: Craig A. Berry <craigberry@mac.com>
> Date:   Sat Jul 25 14:06:34 2009 -0500
> 
>     Save and restore PL_regeol for op inside of regex (RT ##66110)
>     
>     If the op inside of a (?{ }) construct is another regex, the two
>     regexen end up corrupting each others' end-of-string markers,
>     resulting in various pathologies including access violations,
>     stack corruptions, and memory use growing without bound.
>     
>     The change here is intended to be a relatively safe, cheap way to
>     prevent memory errors and makes no attempt to save and restore
>     other aspects of regex state; i.e., general purpose reentrancy
>     for the regex engine is still a TODO.
> -----------------------------------------------------------------------
> 
> Summary of changes:
>  regexec.c |    2 ++
>  1 files changed, 2 insertions(+), 0 deletions(-)
> 
> diff --git a/regexec.c b/regexec.c
> index f3c9540..d3dd612 100644
> --- a/regexec.c
> +++ b/regexec.c
> @@ -3716,6 +3716,7 @@ S_regmatch(pTHX_ regmatch_info *reginfo, regnode *prog)
>  		OP_4tree * const oop = PL_op;
>  		COP * const ocurcop = PL_curcop;
>  		PAD *old_comppad;
> +		char *saved_regeol = PL_regeol;
>  	    
>  		n = ARG(scan);
>  		PL_op = (OP_4tree*)rexi->data->data[n];

What this is all building up to is:

		CALLRUNOPS(aTHX);			/* Scalar context. */

Can that throw an exception that whizzes past the rest of the routine,
including the restoration of PL_regeol?

Or doesn't it matter because this will also cause the abandonment of the outer
regular expression?

(I can't see an ENTER/LEAVE pair here. So the save stack doesn't seem the
right plan either)

> @@ -3741,6 +3742,7 @@ S_regmatch(pTHX_ regmatch_info *reginfo, regnode *prog)
>  		PL_op = oop;
>  		PAD_RESTORE_LOCAL(old_comppad);
>  		PL_curcop = ocurcop;
> +		PL_regeol = saved_regeol;
>  		if (!logical) {
>  		    /* /(?{...})/ */
>  		    sv_setsv(save_scalar(PL_replgv), ret);
> 
> --

Nicholas Clark

Thread Next


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