Skip to content

Stack overflow on EOF* #3359

@KvanTTT

Description

@KvanTTT

Consider the following grammar:

lexer grammar StackoverflowOnClosure;
ClosureEof: EOF*;

It fails with Stackoverflow on empty input:

at org.antlr.v4.runtime.misc.Array2DHashSet.getOrAdd(Array2DHashSet.java:59)
	at org.antlr.v4.runtime.atn.ATNConfigSet.add(ATNConfigSet.java:146)
	at org.antlr.v4.runtime.atn.ATNConfigSet.add(ATNConfigSet.java:122)
	at org.antlr.v4.runtime.atn.LexerATNSimulator.closure(LexerATNSimulator.java:446)
	at org.antlr.v4.runtime.atn.LexerATNSimulator.closure(LexerATNSimulator.java:455)
	at org.antlr.v4.runtime.atn.LexerATNSimulator.closure(LexerATNSimulator.java:455)

And it's freezing on any not empty input.

The samples is extracted from #1943 (comment)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions