develooper Front page | perl.perl5.porters | Postings from March 2003

Re: [patch] Re: [perl #21728] regexp SEGV

Thread Previous | Thread Next
From:
Dave Mitchell
Date:
March 30, 2003 11:15
Subject:
Re: [patch] Re: [perl #21728] regexp SEGV
Message ID:
20030330201526.B5037@fdgroup.com
On Fri, Mar 28, 2003 at 11:53:09PM +0200, Enache Adrian wrote:
> The SSCHECK macro seems to be inappropriately used in regexp.c:174 -
> afaics from scope.[ch], it is designed to grow the savestack by little
> bits. ( 5 items ? - see the definitions of SSCHECK(), savestack_grow(),
> GROW() ).
> 

Wouldn't it be better to to just make SSCHECK call savestack_grow_cnt(),
and have that function grow by the maximum of GROW() and need?

> ---------------------------------------------------------------
> Index: regexec.c
> ===================================================================
> RCS file: /opt/cvsroot/perl/bleadperl/regexec.c,v
> retrieving revision 1.1.1.1
> diff -u -r1.1.1.1 regexec.c
> --- regexec.c	25 Mar 2003 02:00:20 -0000	1.1.1.1
> +++ regexec.c	28 Mar 2003 21:36:59 -0000
> @@ -171,7 +171,7 @@
>  	Perl_croak(aTHX_ "panic: paren_elems_to_push < 0");
>  
>  #define REGCP_OTHER_ELEMS 6
> -    SSCHECK(paren_elems_to_push + REGCP_OTHER_ELEMS);
> +    SSGROW(paren_elems_to_push + REGCP_OTHER_ELEMS);
>      for (p = PL_regsize; p > parenfloor; p--) {
>  /* REGCP_PARENS_ELEMS are pushed per pairs of parentheses. */
>  	SSPUSHINT(PL_regendp[p]);
> Index: scope.c
> ===================================================================
> RCS file: /opt/cvsroot/perl/bleadperl/scope.c,v
> retrieving revision 1.1.1.1
> diff -u -r1.1.1.1 scope.c
> --- scope.c	25 Mar 2003 02:00:20 -0000	1.1.1.1
> +++ scope.c	28 Mar 2003 21:36:05 -0000
> @@ -154,6 +154,13 @@
>      Renew(PL_savestack, PL_savestack_max, ANY);
>  }
>  
> +void
> +Perl_savestack_grow_cnt(pTHX_ I32 need)
> +{
> +    PL_savestack_max = PL_savestack_ix + need;
> +    Renew(PL_savestack, PL_savestack_max, ANY);
> +}
> +
>  #undef GROW
>  
>  void
> Index: scope.h
> ===================================================================
> RCS file: /opt/cvsroot/perl/bleadperl/scope.h,v
> retrieving revision 1.1.1.1
> diff -u -r1.1.1.1 scope.h
> --- scope.h	25 Mar 2003 02:00:20 -0000	1.1.1.1
> +++ scope.h	28 Mar 2003 21:36:54 -0000
> @@ -52,6 +52,7 @@
>  #endif
>  
>  #define SSCHECK(need) if (PL_savestack_ix + need > PL_savestack_max) savestack_grow()
> +#define SSGROW(need) if (PL_savestack_ix + need > PL_savestack_max) savestack_grow_cnt(need)
>  #define SSPUSHINT(i) (PL_savestack[PL_savestack_ix++].any_i32 = (I32)(i))
>  #define SSPUSHLONG(i) (PL_savestack[PL_savestack_ix++].any_long = (long)(i))
>  #define SSPUSHBOOL(p) (PL_savestack[PL_savestack_ix++].any_bool = (p))
> Index: embed.fnc
> ===================================================================
> RCS file: /opt/cvsroot/perl/bleadperl/embed.fnc,v
> retrieving revision 1.1.1.1
> diff -u -r1.1.1.1 embed.fnc
> --- embed.fnc	25 Mar 2003 02:00:20 -0000	1.1.1.1
> +++ embed.fnc	28 Mar 2003 21:33:09 -0000
> @@ -629,6 +629,7 @@
>  Apd	|char*	|savesharedpv	|const char* pv
>  Apd	|char*	|savepvn	|const char* pv|I32 len
>  Ap	|void	|savestack_grow
> +Ap	|void	|savestack_grow_cnt	|I32 need
>  Ap	|void	|save_aelem	|AV* av|I32 idx|SV **sptr
>  Ap	|I32	|save_alloc	|I32 size|I32 pad
>  Ap	|void	|save_aptr	|AV** aptr

-- 
"Emacs isn't a bad OS once you get used to it.
It just lacks a decent editor."

Thread Previous | 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