[Pcre-svn] [418] code/trunk: Adjust tests for workspace over…

Inizio della pagina
Delete this message
Autore: Subversion repository
Data:  
To: pcre-svn
Oggetto: [Pcre-svn] [418] code/trunk: Adjust tests for workspace overflow and relevant comments in pcre2_compile.c
Revision: 418
          http://www.exim.org/viewvc/pcre2?view=rev&revision=418
Author:   ph10
Date:     2015-11-08 14:41:34 +0000 (Sun, 08 Nov 2015)
Log Message:
-----------
Adjust tests for workspace overflow and relevant comments in pcre2_compile.c


Modified Paths:
--------------
    code/trunk/src/pcre2_compile.c
    code/trunk/testdata/testinput11
    code/trunk/testdata/testinput8
    code/trunk/testdata/testinput9
    code/trunk/testdata/testoutput11-16
    code/trunk/testdata/testoutput11-32
    code/trunk/testdata/testoutput8-16
    code/trunk/testdata/testoutput8-32
    code/trunk/testdata/testoutput8-8
    code/trunk/testdata/testoutput9


Modified: code/trunk/src/pcre2_compile.c
===================================================================
--- code/trunk/src/pcre2_compile.c    2015-11-08 14:20:09 UTC (rev 417)
+++ code/trunk/src/pcre2_compile.c    2015-11-08 14:41:34 UTC (rev 418)
@@ -98,15 +98,21 @@


/* This value specifies the size of stack workspace, which is used in different
ways in the different pattern scans. The group-identifying pre-scan uses it to
-handle nesting, and needs it to be 16-bit aligned. During the first compiling
-phase, when determining how much memory is required, the regex is partly
-compiled into this space, but the compiled parts are discarded as soon as they
-can be, so that hopefully there will never be an overrun. The code does,
-however, check for an overrun. In the real compile phase the workspace is used
-for remembering data about numbered groups, provided there are not too many of
-them (if there are, extra memory is acquired). For this phase the memory must
-be 32-bit aligned. */
+handle nesting, and needs it to be 16-bit aligned.

+During the first compiling phase, when determining how much memory is required,
+the regex is partly compiled into this space, but the compiled parts are
+discarded as soon as they can be, so that hopefully there will never be an
+overrun. The code does, however, check for an overrun, which can occur for
+pathological patterns. The size of the workspace depends on LINK_SIZE because
+the length of compiled items varies with this.
+
+In the real compile phase, the workspace is used for remembering data about
+numbered groups, provided there are not too many of them (if there are, extra
+memory is acquired). For this phase the memory must be 32-bit aligned. Having
+defined the size in code units, we set up C32_WORK_SIZE as the number of
+elements in the 32-bit vector. */
+
#define COMPILE_WORK_SIZE (2048*LINK_SIZE) /* Size in code units */

 #define C32_WORK_SIZE \
@@ -860,7 +866,7 @@
   {
   group = GET2(cc, 0);
   cc += IMM2_SIZE;
-  groupinfo = cb->groupinfo[group]; 
+  groupinfo = cb->groupinfo[group];
   if ((groupinfo & GI_NOT_FIXED_LENGTH) != 0) return FFL_NOTFIXED;
   if ((groupinfo & GI_SET_FIXED_LENGTH) != 0)
     return groupinfo & GI_FIXED_LENGTH_MASK;
@@ -909,15 +915,15 @@
     case OP_ASSERT_ACCEPT:
     if (length < 0) length = branchlength;
       else if (length != branchlength) goto ISNOTFIXED;
-    if (*cc != OP_ALT) 
+    if (*cc != OP_ALT)
       {
       if (group > 0)
         {
         groupinfo |= (GI_SET_FIXED_LENGTH | length);
         cb->groupinfo[group] = groupinfo;
-        }  
+        }
       return length;
-      } 
+      }
     cc += 1 + LINK_SIZE;
     branchlength = 0;
     break;
@@ -1203,7 +1209,7 @@
   {
   groupinfo |= GI_NOT_FIXED_LENGTH;
   cb->groupinfo[group] = groupinfo;
-  }   
+  }
 return FFL_NOTFIXED;
 }



Modified: code/trunk/testdata/testinput11
===================================================================
--- code/trunk/testdata/testinput11    2015-11-08 14:20:09 UTC (rev 417)
+++ code/trunk/testdata/testinput11    2015-11-08 14:41:34 UTC (rev 418)
@@ -353,6 +353,4 @@


/(*THEN:\[A]{65501})/expand

-/(?'ABC'\[[bar](]{106}*THEN:\[A]{255}\[)]{107}/expand
-
# End of testinput11

Modified: code/trunk/testdata/testinput8
===================================================================
--- code/trunk/testdata/testinput8    2015-11-08 14:20:09 UTC (rev 417)
+++ code/trunk/testdata/testinput8    2015-11-08 14:41:34 UTC (rev 418)
@@ -157,6 +157,14 @@
 )))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))
 /parens_nest_limit=1000,-fullbincode


+# Use "expand" to create some very long patterns with nested parentheses, in
+# order to test workspace overflow. Again, this varies with code unit width,
+# and even with it fails in two modes, the error offset differs.
+
+/(?'ABC'\[[bar](]{105}*THEN:\[A]{255}\[)]{106}/expand,-fullbincode
+
+/(?'ABC'\[[bar](]{106}*THEN:\[A]{255}\[)]{107}/expand,-fullbincode
+
 /(?(1)(?1)){8,}+()/debug
     abcd



Modified: code/trunk/testdata/testinput9
===================================================================
--- code/trunk/testdata/testinput9    2015-11-08 14:20:09 UTC (rev 417)
+++ code/trunk/testdata/testinput9    2015-11-08 14:41:34 UTC (rev 418)
@@ -258,10 +258,4 @@


/(*MARK:a\x{100}b)z/alt_verbnames

-# Use "expand" to create some very long patterns
-
-/(?'ABC'\[[bar](]{105}*THEN:\[A]{255}\[)]{106}/expand
-
-/(?'ABC'\[[bar](]{106}*THEN:\[A]{255}\[)]{107}/expand
-
# End of testinput9

Modified: code/trunk/testdata/testoutput11-16
===================================================================
--- code/trunk/testdata/testoutput11-16    2015-11-08 14:20:09 UTC (rev 417)
+++ code/trunk/testdata/testoutput11-16    2015-11-08 14:41:34 UTC (rev 418)
@@ -643,7 +643,4 @@


/(*THEN:\[A]{65501})/expand

-/(?'ABC'\[[bar](]{106}*THEN:\[A]{255}\[)]{107}/expand
-Failed: error 186 at offset 594: regular expression is too complicated
-
# End of testinput11

Modified: code/trunk/testdata/testoutput11-32
===================================================================
--- code/trunk/testdata/testoutput11-32    2015-11-08 14:20:09 UTC (rev 417)
+++ code/trunk/testdata/testoutput11-32    2015-11-08 14:41:34 UTC (rev 418)
@@ -646,6 +646,4 @@


/(*THEN:\[A]{65501})/expand

-/(?'ABC'\[[bar](]{106}*THEN:\[A]{255}\[)]{107}/expand
-
# End of testinput11

Modified: code/trunk/testdata/testoutput8-16
===================================================================
--- code/trunk/testdata/testoutput8-16    2015-11-08 14:20:09 UTC (rev 417)
+++ code/trunk/testdata/testoutput8-16    2015-11-08 14:41:34 UTC (rev 418)
@@ -850,6 +850,16 @@
 /parens_nest_limit=1000,-fullbincode
 Failed: error 184 at offset 1540: (?| and/or (?J: or (?x: parentheses are too deeply nested


+# Use "expand" to create some very long patterns with nested parentheses, in
+# order to test workspace overflow. Again, this varies with code unit width,
+# and even with it fails in two modes, the error offset differs.
+
+/(?'ABC'\[[bar](]{105}*THEN:\[A]{255}\[)]{106}/expand,-fullbincode
+Failed: error 186 at offset 594: regular expression is too complicated
+
+/(?'ABC'\[[bar](]{106}*THEN:\[A]{255}\[)]{107}/expand,-fullbincode
+Failed: error 186 at offset 594: regular expression is too complicated
+
/(?(1)(?1)){8,}+()/debug
------------------------------------------------------------------
0 79 Bra

Modified: code/trunk/testdata/testoutput8-32
===================================================================
--- code/trunk/testdata/testoutput8-32    2015-11-08 14:20:09 UTC (rev 417)
+++ code/trunk/testdata/testoutput8-32    2015-11-08 14:41:34 UTC (rev 418)
@@ -849,6 +849,14 @@
 )))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))
 /parens_nest_limit=1000,-fullbincode


+# Use "expand" to create some very long patterns with nested parentheses, in
+# order to test workspace overflow. Again, this varies with code unit width,
+# and even with it fails in two modes, the error offset differs.
+
+/(?'ABC'\[[bar](]{105}*THEN:\[A]{255}\[)]{106}/expand,-fullbincode
+
+/(?'ABC'\[[bar](]{106}*THEN:\[A]{255}\[)]{107}/expand,-fullbincode
+
/(?(1)(?1)){8,}+()/debug
------------------------------------------------------------------
0 79 Bra

Modified: code/trunk/testdata/testoutput8-8
===================================================================
--- code/trunk/testdata/testoutput8-8    2015-11-08 14:20:09 UTC (rev 417)
+++ code/trunk/testdata/testoutput8-8    2015-11-08 14:41:34 UTC (rev 418)
@@ -850,6 +850,15 @@
 /parens_nest_limit=1000,-fullbincode
 Failed: error 184 at offset 1540: (?| and/or (?J: or (?x: parentheses are too deeply nested


+# Use "expand" to create some very long patterns with nested parentheses, in
+# order to test workspace overflow. Again, this varies with code unit width,
+# and even with it fails in two modes, the error offset differs.
+
+/(?'ABC'\[[bar](]{105}*THEN:\[A]{255}\[)]{106}/expand,-fullbincode
+
+/(?'ABC'\[[bar](]{106}*THEN:\[A]{255}\[)]{107}/expand,-fullbincode
+Failed: error 186 at offset 637: regular expression is too complicated
+
/(?(1)(?1)){8,}+()/debug
------------------------------------------------------------------
0 119 Bra

Modified: code/trunk/testdata/testoutput9
===================================================================
--- code/trunk/testdata/testoutput9    2015-11-08 14:20:09 UTC (rev 417)
+++ code/trunk/testdata/testoutput9    2015-11-08 14:41:34 UTC (rev 418)
@@ -364,11 +364,4 @@
 /(*MARK:a\x{100}b)z/alt_verbnames 
 Failed: error 134 at offset 14: character code point value in \x{} or \o{} is too large


-# Use "expand" to create some very long patterns
-
-/(?'ABC'\[[bar](]{105}*THEN:\[A]{255}\[)]{106}/expand
-
-/(?'ABC'\[[bar](]{106}*THEN:\[A]{255}\[)]{107}/expand
-Failed: error 186 at offset 637: regular expression is too complicated
-
# End of testinput9