Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Infinite Loop #365

Open
jcculli opened this issue Mar 9, 2021 · 1 comment
Open

Infinite Loop #365

jcculli opened this issue Mar 9, 2021 · 1 comment

Comments

@jcculli
Copy link

jcculli commented Mar 9, 2021

I'm running into an issue after upgrading from 4.3.0 to any newer version of Antlr4 where a function within the auto-generated parser is running in an infinite loop and memory usage increases rapidly. I'm not very familiar with Antlr4 and didn't create the original grammar files, but my guess is there's an issue with my grammar file and the newer versions of Antlr4. Here's the section of code that is causing me problems (it never makes it out of the while loop due to _alt always having a value of 1):

    [RuleVersion(0)]
public GenadminContext genadmin() {
	GenadminContext _localctx = new GenadminContext(_ctx, State);
	EnterRule(_localctx, 66, RULE_genadmin);
	try {
		int _alt;
		EnterOuterAlt(_localctx, 1);
		{
		State = 692;
		_errHandler.Sync(this);
		_alt = Interpreter.AdaptivePredict(_input,43,_ctx);
		while ( _alt!=2 && _alt!=global::Antlr4.Runtime.Atn.ATN.InvalidAltNumber ) {
			if ( _alt==1 ) {
				{
				{
				State = 689; genadmin_line();
				}
				} 
			}
			State = 694;
			_errHandler.Sync(this);
			_alt = Interpreter.AdaptivePredict(_input,43,_ctx);
		}
		}
	}
	catch (RecognitionException re) {
		_localctx.exception = re;
		_errHandler.ReportError(this, re);
		_errHandler.Recover(this, re);
	}
	finally {
		ExitRule();
	}
	return _localctx;
}
@lextm
Copy link

lextm commented Sep 9, 2023

You might upgrade to ANTLR 4.7 and above (#381) and then see if this issue remains.

Note that all new issues should be reported to https://github.com/antlr/antlr4/issues

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants