"reg_node overrun" when compiling regular expressions in perl

136 Views Asked by At

I am trying to run a script that defines a few (complex) regular expressions: https://github.com/wo/opp-tools/blob/master/rules/Keywords.pm. Whenever I include this module, Perl crashes with the message "panic: reg_node overrun trying to emit 51 at rules/Keywords.pm line 60". This is with Perl v5.14.2 on Ubuntu 12.04. Any ideas what could be the cause of this would be appreciated.

Update: Here is a snippet that causes the problem.

use strict;
use warnings;
use utf8;

my $re_address_word = qr/\b(?:
universit|center|centre|institute?|sciences?|college|research|
avenue|street|philosophy|professor|address|department|
umass
)\b/ix;

our $re_publication_word = qr/\b(?:
forthcoming|editors?|edited|publish\w*|press|volume
to\sappear\sin|draft|editor\w*|reprints?|excerpt|
circulation|cite
)\b/ix;

my $re_notitle = qr/
$re_address_word |
$re_publication_word |
\b(?:thanks?|
   @|
   [12]\d{3}|
   abstract
)/ix;

our $re_title = qr/^
(?!.*$re_notitle?.*)
\p{IsAlpha}    
/x;
1

There are 1 best solutions below

0
Carsten Lygteskov On

I ran into the same problem today when compiling regular expressions consisting of multiple expression. The example below illustrates the code that generated the problem:

    my $cities = qr/(Foo1|Foo2|FooBarss)/;
    ## Solution change ss -> s[s]
    ## my $cities = qr/(Foo1|Foo2|FooBars[s])/;
    my $street = qr/(foo|bar|baz)/;

    $text =~ /$street \s+ $cities/;

The solution was to replace literal ss with s[s], it seems pretty random and I cannot dig up the reference to support it but it works for me.