Make the test for over-complication while auto-possessifying bite sooner.

This commit is contained in:
Philip.Hazel 2016-12-31 13:35:31 +00:00
parent 25dbe146bd
commit 18dd19eae0
4 changed files with 22 additions and 5 deletions

View File

@ -272,6 +272,11 @@ to return PCRE2_ERROR_CALLOUT from a callout.
41. A minor change to pcre2grep: colour reset is now "<esc>[0m" instead of 41. A minor change to pcre2grep: colour reset is now "<esc>[0m" instead of
"<esc>[00m". "<esc>[00m".
42. The limit in the auto-possessification code that was intended to catch
overly-complicated patterns and not spend too much time auto-possessifying was
being reset too often, resulting in very long compile times for some patterns.
Now such patterns are no longer completely auto-possessified.
Version 10.22 29-July-2016 Version 10.22 29-July-2016
-------------------------- --------------------------

View File

@ -1046,8 +1046,10 @@ but some compilers complain about an unreachable statement. */
/* Replaces single character iterations with their possessive alternatives /* Replaces single character iterations with their possessive alternatives
if appropriate. This function modifies the compiled opcode! Hitting a if appropriate. This function modifies the compiled opcode! Hitting a
non-existant opcode may indicate a bug in PCRE2, but it can also be caused if a non-existent opcode may indicate a bug in PCRE2, but it can also be caused if a
bad UTF string was compiled with PCRE2_NO_UTF_CHECK. bad UTF string was compiled with PCRE2_NO_UTF_CHECK. The rec_limit catches
overly complicated or large patterns. In these cases, the check just stops,
leaving the remainder of the pattern unpossessified.
Arguments: Arguments:
code points to start of the byte code code points to start of the byte code
@ -1065,7 +1067,7 @@ PCRE2_UCHAR c;
PCRE2_SPTR end; PCRE2_SPTR end;
PCRE2_UCHAR *repeat_opcode; PCRE2_UCHAR *repeat_opcode;
uint32_t list[8]; uint32_t list[8];
int rec_limit; int rec_limit = 10000;
for (;;) for (;;)
{ {
@ -1080,7 +1082,6 @@ for (;;)
get_chr_property_list(code, utf, cb->fcc, list) : NULL; get_chr_property_list(code, utf, cb->fcc, list) : NULL;
list[1] = c == OP_STAR || c == OP_PLUS || c == OP_QUERY || c == OP_UPTO; list[1] = c == OP_STAR || c == OP_PLUS || c == OP_QUERY || c == OP_UPTO;
rec_limit = 1000;
if (end != NULL && compare_opcodes(end, utf, cb, list, end, &rec_limit)) if (end != NULL && compare_opcodes(end, utf, cb, list, end, &rec_limit))
{ {
switch(c) switch(c)
@ -1137,7 +1138,6 @@ for (;;)
list[1] = (c & 1) == 0; list[1] = (c & 1) == 0;
rec_limit = 1000;
if (compare_opcodes(end, utf, cb, list, end, &rec_limit)) if (compare_opcodes(end, utf, cb, list, end, &rec_limit))
{ {
switch (c) switch (c)

View File

@ -160,4 +160,9 @@
/(*NO_AUTO_POSSESS)\w+(?C1)/BI /(*NO_AUTO_POSSESS)\w+(?C1)/BI
abc\=callout_fail=1 abc\=callout_fail=1
# This test breaks the JIT stack limit
/(|]+){2,2452}/
(|]+){2,2452}
# End of testinput15 # End of testinput15

View File

@ -380,4 +380,11 @@ Subject length lower bound = 1
1 ^^ 1 ^^
No match No match
# This test breaks the JIT stack limit
/(|]+){2,2452}/
(|]+){2,2452}
0:
1:
# End of testinput15 # End of testinput15