Open p5pRT opened 7 years ago
Consider this pattern:
my $pat = qr {
(?(DEFINE)
(?\
This matches a string of digits\, and Perl doesn't complain.
Now\, let's make a small change; instead of trying to match any number of digits\, lets match 4:
my $pat = qr {
(?(DEFINE)
(?\
This pattern works\, but a warning is issued:
Quantifier unexpected on zero-length expression in regex m/
(?(DEFINE)
(?\
The same happens if we replace {4} with {4\,4} or {2\,4}\, and disappears when it's replaced with {4\,}. That is\, a warning happens if the number of repeats is limited. Replacing "(?&digit)" with "[0-9]" makes the warning disappear as well.
This problem is still present in blead.
Consider this pattern:
my $pat = qr {
(?(DEFINE)
(?\
This matches a string of digits\, and Perl doesn't complain.
Now\, let's make a small change; instead of trying to match any number of digits\, lets match 4:
my $pat = qr {
(?(DEFINE)
(?\
This pattern works\, but a warning is issued:
Quantifier unexpected on zero-length expression in regex m/
(?(DEFINE)
(?\
The same happens if we replace {4} with {4\,4} or {2\,4}\, and disappears when it's replaced with {4\,}. That is\, a warning happens if the number of repeats is limited. Replacing "(?&digit)" with "[0-9]" makes the warning disappear as well.
This problem is still present in blead.
It would be helpful to know if this is new behaviour or not. Something makes me think it's newish at least.
Yves
The RT System itself - Status changed from 'new' to 'open'
On Sat\, Aug 19\, 2017 at 02:58:23PM -0700\, yves orton via RT wrote:
On 9 Aug 2017 7:39 am\, "Abigail" \perlbug\-followup@​perl\.org wrote:
# New Ticket Created by Abigail # Please include the string: [perl #131868] # in the subject line of all future correspondence about this issue. # \<URL: https://rt-archive.perl.org/perl5/Ticket/Display.html?id=131868 >
This is a bug report for perl from abigail@abigail.be\, generated with the help of perlbug 1.40 running under perl 5.26.0.
----------------------------------------------------------------- [Please describe your issue here]
Consider this pattern:
my $pat = qr \{ \(?\(DEFINE\) \(?\<digit> \[0\-9\]\) \(?\<digits> \(?&digit\)\+\) \) ^\(?&digits\)$ \}x;
This matches a string of digits\, and Perl doesn't complain.
Now\, let's make a small change; instead of trying to match any number of digits\, lets match 4:
my $pat = qr \{ \(?\(DEFINE\) \(?\<digit> \[0\-9\]\) \(?\<digits> \(?&digit\)\+\) \) ^\(?&digits\)$ \}x;
This pattern works\, but a warning is issued:
Quantifier unexpected on zero\-length expression in regex m/ \(?\(DEFINE\) \(?\<digit> \[0\-9\]\) \(?\<digits> \(?&digit\)\{4\}\) \) ^\(?&digits\)$ / at /tmp/bar line 15\.
The same happens if we replace {4} with {4\,4} or {2\,4}\, and disappears when it's replaced with {4\,}. That is\, a warning happens if the number of repeats is limited. Replacing "(?&digit)" with "[0-9]" makes the warning disappear as well.
This problem is still present in blead.
It would be helpful to know if this is new behaviour or not. Something makes me think it's newish at least.
It warns for me in 5.22.0\, but not in 5.20.0
Abigail
On Sun\, Aug 20\, 2017 at 10:16:16PM +0200\, Abigail wrote:
On Sat\, Aug 19\, 2017 at 02:58:23PM -0700\, yves orton via RT wrote:
On 9 Aug 2017 7:39 am\, "Abigail" \perlbug\-followup@​perl\.org wrote: This pattern works\, but a warning is issued:
Quantifier unexpected on zero\-length expression in regex m/ \(?\(DEFINE\) \(?\<digit> \[0\-9\]\) \(?\<digits> \(?&digit\)\{4\}\) \) ^\(?&digits\)$ / at /tmp/bar line 15\.
The same happens if we replace {4} with {4\,4} or {2\,4}\, and disappears when it's replaced with {4\,}. That is\, a warning happens if the number of repeats is limited. Replacing "(?&digit)" with "[0-9]" makes the warning disappear as well.
This problem is still present in blead.
It would be helpful to know if this is new behaviour or not. Something makes me think it's newish at least.
It warns for me in 5.22.0\, but not in 5.20.0
Bisects to:
a51d618a82a7057c3aabb600a7a8691d27f44a34 is the first bad commit commit a51d618a82a7057c3aabb600a7a8691d27f44a34 Author: Yves Orton \demerphq@​gmail\.com Date: Fri Sep 19 19:57:34 2014 +0200
rt 122283 - do not recurse into GOSUB/GOSTART when not SCF_DO_SUBSTR
See also comments in patch. A complex regex "grammar" like that in
RT 122283 causes perl to take literally forever\, and exhaust all
memory during the pattern optimization phase.
Unfortunately I could not track down exacty why this occured\, but
it was very clear that the excessive recursion was unnecessary and
excessive. By simply eliminating the unncessary recursion performance
goes back to being acceptable.
I have not thought of a good way to test this change\, so this patch
does not include any tests. Perhaps we can test it using alarm\, but
I will follow up on that later.
-- The crew of the Enterprise encounter an alien life form which is surprisingly neither humanoid nor made from pure energy. -- Things That Never Happen in "Star Trek" #22
On 11 September 2017 at 09:17\, Dave Mitchell \davem@​iabyn\.com wrote:
On Sun\, Aug 20\, 2017 at 10:16:16PM +0200\, Abigail wrote:
On Sat\, Aug 19\, 2017 at 02:58:23PM -0700\, yves orton via RT wrote:
On 9 Aug 2017 7:39 am\, "Abigail" \perlbug\-followup@​perl\.org wrote: This pattern works\, but a warning is issued:
Quantifier unexpected on zero\-length expression in regex m/ \(?\(DEFINE\) \(?\<digit> \[0\-9\]\) \(?\<digits> \(?&digit\)\{4\}\) \) ^\(?&digits\)$ / at /tmp/bar line 15\.
The same happens if we replace {4} with {4\,4} or {2\,4}\, and disappears when it's replaced with {4\,}. That is\, a warning happens if the number of repeats is limited. Replacing "(?&digit)" with "[0-9]" makes the warning disappear as well.
This problem is still present in blead.
It would be helpful to know if this is new behaviour or not. Something makes me think it's newish at least.
It warns for me in 5.22.0\, but not in 5.20.0
Bisects to:
a51d618a82a7057c3aabb600a7a8691d27f44a34 is the first bad commit commit a51d618a82a7057c3aabb600a7a8691d27f44a34 Author: Yves Orton \demerphq@​gmail\.com Date: Fri Sep 19 19:57:34 2014 +0200
rt 122283 \- do not recurse into GOSUB/GOSTART when not SCF\_DO\_SUBSTR See also comments in patch\. A complex regex "grammar" like that in RT 122283 causes perl to take literally forever\, and exhaust all memory during the pattern optimization phase\. Unfortunately I could not track down exacty why this occured\, but it was very clear that the excessive recursion was unnecessary and excessive\. By simply eliminating the unncessary recursion performance goes back to being acceptable\. I have not thought of a good way to test this change\, so this patch does not include any tests\. Perhaps we can test it using alarm\, but I will follow up on that later\.
Fixed in 0e3f4440d849cf8fca676f87e574164e33cf2e13
Thanks for the report. Feel like writing a test? ;-)
Yves
-- perl -Mre=debug -e "/just|another|perl|hacker/"
On Wed\, Sep 13\, 2017 at 06:05:43PM +0200\, demerphq wrote:
On 11 September 2017 at 09:17\, Dave Mitchell \davem@​iabyn\.com wrote:
On Sun\, Aug 20\, 2017 at 10:16:16PM +0200\, Abigail wrote:
On Sat\, Aug 19\, 2017 at 02:58:23PM -0700\, yves orton via RT wrote:
On 9 Aug 2017 7:39 am\, "Abigail" \perlbug\-followup@​perl\.org wrote: This pattern works\, but a warning is issued:
Quantifier unexpected on zero\-length expression in regex m/ \(?\(DEFINE\) \(?\<digit> \[0\-9\]\) \(?\<digits> \(?&digit\)\{4\}\) \) ^\(?&digits\)$ / at /tmp/bar line 15\.
The same happens if we replace {4} with {4\,4} or {2\,4}\, and disappears when it's replaced with {4\,}. That is\, a warning happens if the number of repeats is limited. Replacing "(?&digit)" with "[0-9]" makes the warning disappear as well.
This problem is still present in blead.
It would be helpful to know if this is new behaviour or not. Something makes me think it's newish at least.
It warns for me in 5.22.0\, but not in 5.20.0
Bisects to:
a51d618a82a7057c3aabb600a7a8691d27f44a34 is the first bad commit commit a51d618a82a7057c3aabb600a7a8691d27f44a34 Author: Yves Orton \demerphq@​gmail\.com Date: Fri Sep 19 19:57:34 2014 +0200
rt 122283 \- do not recurse into GOSUB/GOSTART when not SCF\_DO\_SUBSTR See also comments in patch\. A complex regex "grammar" like that in RT 122283 causes perl to take literally forever\, and exhaust all memory during the pattern optimization phase\. Unfortunately I could not track down exacty why this occured\, but it was very clear that the excessive recursion was unnecessary and excessive\. By simply eliminating the unncessary recursion performance goes back to being acceptable\. I have not thought of a good way to test this change\, so this patch does not include any tests\. Perhaps we can test it using alarm\, but I will follow up on that later\.
Fixed in 0e3f4440d849cf8fca676f87e574164e33cf2e13
Thanks for the report. Feel like writing a test? ;-)
Thanks for the patch. Test added in commit c2b4244a1cd5bb89e0df552475efbb59ea37e706.
Abigail
Thank you! Cheers\, yves
On 14 Sep 2017 00:21\, "Abigail" \abigail@​abigail\.be wrote:
On Wed\, Sep 13\, 2017 at 06:05:43PM +0200\, demerphq wrote:
On 11 September 2017 at 09:17\, Dave Mitchell \davem@​iabyn\.com wrote:
On Sun\, Aug 20\, 2017 at 10:16:16PM +0200\, Abigail wrote:
On Sat\, Aug 19\, 2017 at 02:58:23PM -0700\, yves orton via RT wrote:
On 9 Aug 2017 7:39 am\, "Abigail" \perlbug\-followup@​perl\.org wrote: This pattern works\, but a warning is issued:
Quantifier unexpected on zero\-length expression in regex m/ \(?\(DEFINE\) \(?\<digit> \[0\-9\]\) \(?\<digits> \(?&digit\)\{4\}\) \) ^\(?&digits\)$ / at /tmp/bar line 15\.
The same happens if we replace {4} with {4\,4} or {2\,4}\, and disappears when it's replaced with {4\,}. That is\, a warning happens if the number of repeats is limited. Replacing "(?&digit)" with "[0-9]" makes the warning disappear as well.
This problem is still present in blead.
It would be helpful to know if this is new behaviour or not. Something makes me think it's newish at least.
It warns for me in 5.22.0\, but not in 5.20.0
Bisects to:
a51d618a82a7057c3aabb600a7a8691d27f44a34 is the first bad commit commit a51d618a82a7057c3aabb600a7a8691d27f44a34 Author: Yves Orton \demerphq@​gmail\.com Date: Fri Sep 19 19:57:34 2014 +0200
rt 122283 \- do not recurse into GOSUB/GOSTART when not
SCF_DO_SUBSTR
See also comments in patch\. A complex regex "grammar" like that in RT 122283 causes perl to take literally forever\, and exhaust all memory during the pattern optimization phase\. Unfortunately I could not track down exacty why this occured\, but it was very clear that the excessive recursion was unnecessary and excessive\. By simply eliminating the unncessary recursion
performance goes back to being acceptable.
I have not thought of a good way to test this change\, so this patch does not include any tests\. Perhaps we can test it using alarm\, but I will follow up on that later\.
Fixed in 0e3f4440d849cf8fca676f87e574164e33cf2e13
Thanks for the report. Feel like writing a test? ;-)
Thanks for the patch. Test added in commit c2b4244a1cd5bb89e0df552475efbb59ea37e706.
Abigail
Migrated from rt.perl.org#131868 (status was 'open')
Searchable as RT131868$