diff options
author | ph10 <ph10@6239d852-aaf2-0410-a92c-79f79f948069> | 2016-12-31 13:35:31 +0000 |
---|---|---|
committer | ph10 <ph10@6239d852-aaf2-0410-a92c-79f79f948069> | 2016-12-31 13:35:31 +0000 |
commit | c41a16b0509702e8f61a04621c82c4f6f4fa9c79 (patch) | |
tree | 078347abfd15f27fd273685ad641b752149f3edd | |
parent | 6a5159dd1b259d6a296c35de213c6c4202566284 (diff) | |
download | pcre2-c41a16b0509702e8f61a04621c82c4f6f4fa9c79.tar.gz |
Make the test for over-complication while auto-possessifying bite sooner.
git-svn-id: svn://vcs.exim.org/pcre2/code/trunk@635 6239d852-aaf2-0410-a92c-79f79f948069
-rw-r--r-- | ChangeLog | 5 | ||||
-rw-r--r-- | src/pcre2_auto_possess.c | 10 | ||||
-rw-r--r-- | testdata/testinput15 | 5 | ||||
-rw-r--r-- | testdata/testoutput15 | 7 |
4 files changed, 22 insertions, 5 deletions
@@ -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 "<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 -------------------------- diff --git a/src/pcre2_auto_possess.c b/src/pcre2_auto_possess.c index bcc3d9a..6946d51 100644 --- a/src/pcre2_auto_possess.c +++ b/src/pcre2_auto_possess.c @@ -1046,8 +1046,10 @@ but some compilers complain about an unreachable statement. */ /* Replaces single character iterations with their possessive alternatives 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 -bad UTF string was compiled with PCRE2_NO_UTF_CHECK. +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. The rec_limit catches +overly complicated or large patterns. In these cases, the check just stops, +leaving the remainder of the pattern unpossessified. Arguments: code points to start of the byte code @@ -1065,7 +1067,7 @@ PCRE2_UCHAR c; PCRE2_SPTR end; PCRE2_UCHAR *repeat_opcode; uint32_t list[8]; -int rec_limit; +int rec_limit = 10000; for (;;) { @@ -1080,7 +1082,6 @@ for (;;) get_chr_property_list(code, utf, cb->fcc, list) : NULL; 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)) { switch(c) @@ -1137,7 +1138,6 @@ for (;;) list[1] = (c & 1) == 0; - rec_limit = 1000; if (compare_opcodes(end, utf, cb, list, end, &rec_limit)) { switch (c) diff --git a/testdata/testinput15 b/testdata/testinput15 index 77b9698..b1aaf78 100644 --- a/testdata/testinput15 +++ b/testdata/testinput15 @@ -160,4 +160,9 @@ /(*NO_AUTO_POSSESS)\w+(?C1)/BI abc\=callout_fail=1 +# This test breaks the JIT stack limit + +/(|]+){2,2452}/ + (|]+){2,2452} + # End of testinput15 diff --git a/testdata/testoutput15 b/testdata/testoutput15 index 8c5985d..b6527c9 100644 --- a/testdata/testoutput15 +++ b/testdata/testoutput15 @@ -380,4 +380,11 @@ Subject length lower bound = 1 1 ^^ No match +# This test breaks the JIT stack limit + +/(|]+){2,2452}/ + (|]+){2,2452} + 0: + 1: + # End of testinput15 |