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

Re: [perl #126182] /(.(?2))((?<=(?=(?1)).))/ hangs and eats allavailable RAM

Thread Previous | Thread Next
From:
demerphq
Date:
March 6, 2016 17:09
Subject:
Re: [perl #126182] /(.(?2))((?<=(?=(?1)).))/ hangs and eats allavailable RAM
Message ID:
CANgJU+XBj69GO0bgfvHvuYuyTZNaAv3iQ+khNQexUwT6XoCvDA@mail.gmail.com
On 2 March 2016 at 11:01, demerphq <demerphq@gmail.com> wrote:
> On 2 March 2016 at 00:58, James E Keenan via RT
> <perlbug-followup@perl.org> wrote:
>> And here it is at today's blead (on Linux x86_64):
>> #####
>> $ git show | head -1
>> commit f24480bcc6bbe9061c0ff1595df8d3eadb2ab8db
>>
>> $ ulimit -Sv 1048576 && ./perl -Ilib -e '"a"=~/(.(?2))((?<=(?=(?1)).))/'
>> Out of memory!
>
> hope to get to it sooner than later.

And this should be fixed now with:

ba6840fbf2fdde3e7f1bda1a26f46c901f36d5ec

This might need a doc fix. It is no longer illegal to do "infinite
recursion", instead the match "fails" to match at the given position.

so for instance this:

/a(?R)?b/

now matches "ab", "aabb", etc.

I am not sure this is the best wording, but now a pattern sub-routine
will fail to match if entered recursively from the same position. Note
this does not apply to EVAL (??{ ... }) style recursion, only GOSUB
style recursion (?&foo).

Eg:

"foobar"=~/(?&y)(?(DEFINE)(?<x>(?&y)?foo)(?<y>(?&x)?bar))/

matches. However:

"foobar"=~/(?&y)(?(DEFINE)(?<x>(?&y)foo)(?<y>(?&x)bar))/

does not, and produces output like this:

floating "foobar" at 0..9223372036854775807 (checking floating) minlen 6
Matching REx "(?&y)(?(DEFINE)(?<x>(?&y)foo)(?<y>(?&x)bar))" against "foobar"
Intuit: trying to determine minimum start position...
  doing 'check' fbm scan, [0..6] gave 0
  Found floating substr "foobar" at offset 0 (rx_origin now 0)...
  (multiline anchor test skipped)
Intuit: Successfully guessed: match at offset 0
   0 <> <foobar>             |  1:GOSUB2[+16:17] 'y'(4)
   0 <> <foobar>             | 17:  OPEN2 'y'(19)
   0 <> <foobar>             | 19:  GOSUB1[-11:8] 'x'(22)
   0 <> <foobar>             |  8:    OPEN1 'x'(10)
   0 <> <foobar>             | 10:    GOSUB2[+7:17] 'y'(13)
                                      pattern left-recursion without
consuming input always fails...
                                      failed...
Match failed
Freeing REx: "(?&y)(?(DEFINE)(?<x>(?&y)foo)(?<y>(?&x)bar))"

So I think this ticket can be closed.

cheers,
Yves





-- 
perl -Mre=debug -e "/just|another|perl|hacker/"

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