FAQ

On Mon, May 30, 2016 at 03:49:06PM +0200, Aristotle Pagaltzis wrote:
* 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 what
the user likely expected it to even if it worked, after all.
The following seems to detect it for pp_match() while not failing anything
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

Search Discussions

Discussion Posts

Previous

Follow ups

Related Discussions

Discussion Navigation
viewthread | post
posts ‹ prev | 15 of 16 | next ›
Discussion Overview
groupperl5-porters @
categoriesperl
postedMay 23, '16 at 5:48p
activeMay 30, '16 at 9:13p
posts16
users5
websiteperl.org

People

Translate

site design / logo © 2022 Grokbase