-
Notifications
You must be signed in to change notification settings - Fork 3.4k
Closed
Milestone
Description
While trying to update the Antlr version in my project (https://github.com/nielsbasjes/yauaa) from version 4.6 to 4.7 I ran into an unexpected Stackoverflow.
I have managed to reduce the problem reproduction to the following very small grammar.
( Full code available via https://github.com/nielsbasjes/Antlr47Stackoverflow )
Experiment.g4
grammar Experiment;
WORD : [a-zA-Z0-9-+]+ ;
NUMBER : [0-9]+ ;
start: 'Something';
and the a simple Java unit test to do a parse action against this
package nl.basjes;
import org.antlr.v4.runtime.ANTLRInputStream;
import org.junit.Test;
public class TestAntlr47 {
@Test
public void simpleTest(){
ANTLRInputStream input = new ANTLRInputStream("Something"); // This API works in both 4.6 and 4.7
ExperimentLexer lexer = new ExperimentLexer(input);
lexer.getAllTokens();
}
}
The top of the stack trace looks like this:
-------------------------------------------------------
T E S T S
-------------------------------------------------------
Running nl.basjes.TestAntlr47
Tests run: 1, Failures: 0, Errors: 1, Skipped: 0, Time elapsed: 0.084 sec <<< FAILURE!
simpleTest(nl.basjes.TestAntlr47) Time elapsed: 0.055 sec <<< ERROR!
java.lang.StackOverflowError
at org.antlr.v4.runtime.atn.LexerATNSimulator.getEpsilonTarget(LexerATNSimulator.java:475)
at org.antlr.v4.runtime.atn.LexerATNSimulator.closure(LexerATNSimulator.java:456)
at org.antlr.v4.runtime.atn.LexerATNSimulator.closure(LexerATNSimulator.java:458)
at org.antlr.v4.runtime.atn.LexerATNSimulator.closure(LexerATNSimulator.java:458)
at org.antlr.v4.runtime.atn.LexerATNSimulator.closure(LexerATNSimulator.java:458)
at org.antlr.v4.runtime.atn.LexerATNSimulator.closure(LexerATNSimulator.java:458)
at org.antlr.v4.runtime.atn.LexerATNSimulator.closure(LexerATNSimulator.java:458)
at org.antlr.v4.runtime.atn.LexerATNSimulator.closure(LexerATNSimulator.java:458)
at org.antlr.v4.runtime.atn.LexerATNSimulator.closure(LexerATNSimulator.java:458)
at org.antlr.v4.runtime.atn.LexerATNSimulator.closure(LexerATNSimulator.java:458)
at org.antlr.v4.runtime.atn.LexerATNSimulator.closure(LexerATNSimulator.java:458)
at org.antlr.v4.runtime.atn.LexerATNSimulator.closure(LexerATNSimulator.java:458)