You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
perl5 regexp: wrong content in capture buffer #16250
The following test program shows a wrong content of a capture
group depending on the content of the string to be matched.
4 test strings are matched. Case 2 yields a wrong result,
as $1 should be undefined in this case. Cases 1, 3 and 4 with
different string lengths yield the correct result.
It seems to me that capture buffer $1 is not cleared
correctly on backtracking.
BTW, the same error occurs also under Perl 5.16.3, so the bug
may be old.
The nature of the regexp is such that where $1 is captured it should
contain the four characters that immediately precede the five characters
captured in $2. In the second case above, the two captures overlap,
which is incorrect; $1 should be undef instead. The other cases yield
correct results.
BTW, the same error occurs also under Perl 5.16.3, so the bug
may be old.
Much older than that. The same thing happens on 5.005_03, which is the
oldest that I have handy.
I have a bit if familiarity with this, but the prospect of dealing
with nested lookaheads and lookbehinds fills me with horror, and does
not surprise me that it does not work well.
I have a bit if familiarity with this, but the prospect of dealing
with nested lookaheads and lookbehinds fills me with horror, and does
not surprise me that it does not work well.
The lookahead isn't required to trigger the bug; this still includes 'd'
in both $1 and $2:
Activity
p5pRT commentedon Nov 16, 2017
From wolf-dietrich_moeller@t-online.de
The following test program shows a wrong content of a capture
group depending on the content of the string to be matched.
4 test strings are matched. Case 2 yields a wrong result,
as $1 should be undefined in this case. Cases 1, 3 and 4 with
different string lengths yield the correct result.
It seems to me that capture buffer $1 is not cleared
correctly on backtracking.
BTW, the same error occurs also under Perl 5.16.3, so the bug
may be old.
Perl Info
p5pRT commentedon Nov 16, 2017
From zefram@fysh.org
Wolf-Dietrich Moeller wrote:
I concur with your analysis. The output that I get is
$1: "undef" $2: "cd567"
$1: "abcd" $2: "de567"
$1: "abcd" $2: "ef567"
$1: "bcde" $2: "fg567"
The nature of the regexp is such that where $1 is captured it should
contain the four characters that immediately precede the five characters
captured in $2. In the second case above, the two captures overlap,
which is incorrect; $1 should be undef instead. The other cases yield
correct results.
Much older than that. The same thing happens on 5.005_03, which is the
oldest that I have handy.
-zefram
p5pRT commentedon Nov 16, 2017
The RT System itself - Status changed from 'new' to 'open'
p5pRT commentedon Nov 16, 2017
From @demerphq
I have a bit if familiarity with this, but the prospect of dealing
with nested lookaheads and lookbehinds fills me with horror, and does
not surprise me that it does not work well.
Yves
--
perl -Mre=debug -e "/just|another|perl|hacker/"
p5pRT commentedon Nov 16, 2017
From @Smylers
demerphq wrote:
The lookahead isn't required to trigger the bug; this still includes 'd'
in both
$1and$2:Smylers
regex: retire fixed capture tests from run/todo.t
jkeenan commentedon Oct 18, 2026
@demerphq,
I believe that your commit in GH #24974 (77af3ea) addressed the problem in this ticket. Earlier today I moved the TODO-ed test created for this issue from
t/run/todo.ttot/re/pat.t.I believe that makes this ticket closable. Do you agree? Thanks.
regex: retire fixed capture tests from run/todo.t
regex: retire fixed capture tests from run/todo.t
regex: retire fixed capture tests from run/todo.t
regex: retire fixed capture tests from run/todo.t
regex: retire fixed capture tests from run/todo.t