develooper Front page | perl.perl5.porters | Postings from July 2001

bleadperl bug: regex re-entrance

Thread Next
Jeff 'japhy/Marillion' Pinyan
July 24, 2001 21:39
bleadperl bug: regex re-entrance
Message ID:
(Please note that this has not been sent via perlbug, but is
correspondance with Hugo, and I decided to let you all know about it.  It
seems there are severe problems in executing a regex inside another regex,
which leads me to believe that the engine really is NOT re-entrant for
pattern matching -- these problems don't necessarily exist for
substitutions, as I have seen Damian do regexes in the RHS of a s///g.)


  "baaz" =~ m{
    (?(?{ reverse("$`$&") =~ /^z.*a/ })
      (?=) | (?!)

This dumps core (or gives a bus error, or some other nastiness).  I
suspect the problem is based upon the need for ACTUAL EVALUATION of a
regex -- when we merely use /z/ or /za/, Perl can use an index()-like
approach -- but as soon as I make it work by employing regex-specific
notes, it breaks down.

This is shown here:

  "baaz" =~ m{
    (?(?{ reverse("$`$&") =~ /z/ })
      (?=) | (?!)

That succeeds.  The following make it break:


Using the modifier /m or /s is not problem-inducing, but only because they
effect they have is never carried out, due to the fact that no anchors nor
the . are ever allowed in this embedded regex.

This strongly leads me to believe that Perl is not ACTUALLY doing an
internal regex, and is instead seeing that the regex can really be
optimized into a substring match.

Jeff "japhy" Pinyan
I am Marillion, the wielder of Ringril, known as Hesinaur, the Winter-Sun.
Are you a Monk?
Perl Programmer at RiskMetrics Group, Inc.
Acacia Fraternity, Rensselaer Chapter.         Brother #734
**      Manning Publications, Co, is publishing my Perl Regex book      **

Thread Next Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at | Group listing | About