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

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

Thread Previous | Thread Next
From:
Enache Adrian
Date:
March 28, 2003 13:55
Subject:
[patch] Re: [perl #21728] regexp SEGV
Message ID:
20030328215309.GA6413@ratsnest.hole
On Fri, Mar 28, 2003 at 03:14:15PM -0000, Hugo van der Sanden wrote:
> # New Ticket Created by  Hugo van der Sanden 
> # Please include the string:  [perl #21728]
> # in the subject line of all future correspondence about this issue. 
> # <URL: http://rt.perl.org/rt2/Ticket/Display.html?id=21728 >
> 
> 
> This is a bug report for perl from hv@crypt.org
> generated with the help of perlbug 1.34 running under perl@19077
> 
> -----------------------------------------------------------------
> [Please enter your report here]
> 
> perl -e '"ab" =~ join "|", ("(c)") x shift, "(?:([ab])(?!c))*"' 36

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() ).

Please try this patch ( make regen needed ).

Regards
Adi

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

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