Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Test for RT #124333 (huge alternation SEGV).
  • Loading branch information
jnthn committed Apr 24, 2015
1 parent 35b2288 commit f687502
Showing 1 changed file with 113 additions and 1 deletion.
114 changes: 113 additions & 1 deletion S05-metasyntax/longest-alternative.t
@@ -1,7 +1,7 @@
use v6;
use Test;

plan 41;
plan 42;

#L<S05/Unchanged syntactic features/"While the syntax of | does not change">

Expand Down Expand Up @@ -311,4 +311,116 @@ my $str = 'a' x 7;
fragment => 「bar」
END
}

# RT #124333
# This exposed a dynamic optimizer bug, due to the huge number of basic blocks
# a token with a load of alternations produces.
{
my grammar WithHugeToken {
token TOP {
<huge>+
}
token huge {
<[\x[0041]..\x[005A]]>
| <[\x[0061]..\x[007A]]>
| <[\x[0388]..\x[038A]]>
| <[\x[038E]..\x[03A1]]>
| <[\x[03A3]..\x[03CE]]>
| <[\x[03D0]..\x[03D7]]>
| <[\x[03DA]..\x[03F3]]>
| <[\x[0400]..\x[0481]]>
| <[\x[048C]..\x[04C4]]>
| <[\x[04C7]..\x[04C8]]>
| <[\x[04CB]..\x[04CC]]>
| <[\x[04D0]..\x[04F5]]>
| <[\x[04F8]..\x[04F9]]>
| <[\x[0531]..\x[0556]]>
| <[\x[06E5]..\x[06E6]]>
| <[\x[06FA]..\x[06FC]]>
| <[\x[1312]..\x[1315]]>
| <[\x[1318]..\x[131E]]>
| <[\x[1320]..\x[1346]]>
| <[\x[1348]..\x[135A]]>
| <[\x[13A0]..\x[13B0]]>
| <[\x[13B1]..\x[13F4]]>
| <[\x[1401]..\x[1676]]>
| <[\x[1681]..\x[169A]]>
| <[\x[16A0]..\x[16EA]]>
| <[\x[1780]..\x[17B3]]>
| <[\x[1820]..\x[1877]]>
| <[\x[1880]..\x[18A8]]>
| <[\x[1E00]..\x[1E9B]]>
| <[\x[1EA0]..\x[1EE0]]>
| <[\x[1EE1]..\x[1EF9]]>
| <[\x[1F00]..\x[1F15]]>
| <[\x[1F18]..\x[1F1D]]>
| <[\x[1F20]..\x[1F39]]>
| <[\x[1F3A]..\x[1F45]]>
| <[\x[1F48]..\x[1F4D]]>
| <[\x[1F50]..\x[1F57]]>
| <[\x[210A]..\x[2113]]>
| <[\x[2119]..\x[211D]]>
| <[\x[212A]..\x[212D]]>
| <[\x[212F]..\x[2131]]>
| <[\x[2133]..\x[2139]]>
| <[\x[2160]..\x[2183]]>
| <[\x[3005]..\x[3007]]>
| <[\x[3021]..\x[3029]]>
| <[\x[3031]..\x[3035]]>
| <[\x[3038]..\x[303A]]>
| <[\x[3041]..\x[3094]]>
| <[\x[309D]..\x[309E]]>
| <[\x[30A1]..\x[30FA]]>
| <[\x[30FC]..\x[30FE]]>
| <[\x[3105]..\x[312C]]>
| <[\x[3131]..\x[318E]]>
| <[\x[31A0]..\x[31B7]]>
| <[\x[A000]..\x[A48C]]>
| <[\x[F900]..\x[FA2D]]>
| <[\x[FB00]..\x[FB06]]>
| <[\x[FB13]..\x[FB17]]>
| <[\x[FB1F]..\x[FB28]]>
| <[\x[FB2A]..\x[FB36]]>
| <[\x[FB38]..\x[FB3C]]>
| <[\x[FB40]..\x[FB41]]>
| <[\x[FB43]..\x[FB44]]>
| <[\x[FB46]..\x[FBB1]]>
| <[\x[FBD3]..\x[FD3D]]>
| <[\x[FD50]..\x[FD8F]]>
| <[\x[FD92]..\x[FDC7]]>
| <[\x[FDF0]..\x[FDFB]]>
| <[\x[FE70]..\x[FE72]]>
| <[\x[FE76]..\x[FEFC]]>
| <[\x[FF21]..\x[FF3A]]>
| <[\x[FF41]..\x[FF5A]]>
| <[\x[FF66]..\x[FFBE]]>
| <[\x[FFC2]..\x[FFC7]]>
| <[\x[FFCA]..\x[FFCF]]>
| <[\x[FFD2]..\x[FFD7]]>
| <[\x[FFDA]..\x[FFDC]]>
| \x[038C]
| \x[0559]
| \x[06D5]
| \x[0710]
| \x[1310]
| \x[2115]
| \x[2124]
| \x[2126]
| \x[2128]
| \x[3400]
| \x[4DB5]
| \x[4E00]
| \x[9FA5]
| \x[AC00]
| \x[D7A3]
| \x[FB1D]
| \x[FB3E]
| \x[FE74]
}
}

lives_ok { WithHugeToken.parse('a' x 10000) },
'token with huge number of alternations does not explode when used many times';
}

# vim: ft=perl6 et

0 comments on commit f687502

Please sign in to comment.