On Mon, May 30, 2016 at 03:49:06PM +0200, Aristotle Pagaltzis wrote:
* Dave Mitchell [2016-05-30 15:09]:
the user likely expected it to even if it worked, after all.
* Dave Mitchell [2016-05-30 15:09]:
As has been pointed out elsewhere in this ticket, an empty pattern is
interpreted as the "last successful match". The re-eval mechanism
takes this as being the currently executing pattern, and so you get
infinite recursion.
Is it possible to detect this case and die instead? It wouldn’t do whatinterpreted as the "last successful match". The re-eval mechanism
takes this as being the currently executing pattern, and so you get
infinite recursion.
the user likely expected it to even if it worked, after all.
in the test suite. If no-one objects, I can work it up into a proper fix
that handles pp_subst() etc, and has tests.
I'm not sure if there are mutual recursion scenarios which could still
slip past though.
$ perl5240 -e'"a" =~ /(?{ m{} })/'
Segmentation fault (core dumped)
$ ./perl -e'"a" =~ /(?{ m{} })/'
panic: XXX curpm recursion
$
diff --git a/pp_hot.c b/pp_hot.c
index 223169b..5292383 100644
--- a/pp_hot.c
+++ b/pp_hot.c
@@ -1767,6 +1767,8 @@ PP(pp_match)
if (!ReANY(rx)->mother_re && !RX_PRELEN(rx)
&& PL_curpm) {
pm = PL_curpm;
+ if (pm == PL_reg_curpm)
+ Perl_croak(aTHX_ "panic: XXX curpm recursion\n");
rx = PM_GETRE(pm);
}
--
Overhead, without any fuss, the stars were going out.
-- Arthur C Clarke