-
Notifications
You must be signed in to change notification settings - Fork 3.3k
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
avoid java.lang.StackOverflowError #1105
Comments
@WolfgangFahl Did you get an error from antlr during code generation? It's an optional token or something. |
@WolfgangFahl If this is an issue of actual stack size because of parsing, you can increase the stack size remarkably big in Java ;) Did you see an error message when you generated code? Can I close this? |
@parrt I have the same problem. I increased the stack size but it didn't work. |
Increasing the stacksize obviously won't help. No please don't close this. It would be helpful to get an avoidance/debug help implemented. |
it's an infinite loop issue when someone puts a lexer rule that can match the empty string I believe. detecting infinite loops in that case might be undecidable. (halting problem) |
Seems like it's related to #2860 Also, I don't think it's about a halting problem rather a bug in runtime. Because there is stack overflow even for such a simple sample (for input TOKEN1: '\'' FRAGMENT1 '\'';
fragment FRAGMENT1: ('x'|)+; But everything works fine if an empty alternative is replaced with optional: TOKEN2: '\'' FRAGMENT2 '\'';
fragment FRAGMENT2: 'x'*; |
This is definitely not a halting problem since the stack is a limited resource and it should be avoided to overrun the limit. The limit is known and therefore simple counting can decide when the limit is reached (or almost reached). |
It seems like I've fixed this case. Lexer should throw |
@parrt it should be closed as well :) |
### What changes were proposed in this pull request? This pr is aims upgrade `antlr4` from 4.9.3 to 4.13.1 ### Why are the changes needed? After 4.10, antlr4 is using Java 11 for the source code and the compiled .class files for the ANTLR tool. There are some bug fix and Improvements after 4.9.3: - antlr/antlr4#3399 - antlr/antlr4#1105 - antlr/antlr4#2788 - antlr/antlr4#3957 - antlr/antlr4#4394 The full release notes as follows: - https://github.com/antlr/antlr4/releases/tag/4.13.1 - https://github.com/antlr/antlr4/releases/tag/4.13.0 - https://github.com/antlr/antlr4/releases/tag/4.12.0 - https://github.com/antlr/antlr4/releases/tag/4.11.1 - https://github.com/antlr/antlr4/releases/tag/4.11.0 - https://github.com/antlr/antlr4/releases/tag/4.10.1 - https://github.com/antlr/antlr4/releases/tag/4.10 ### Does this PR introduce _any_ user-facing change? No ### How was this patch tested? Pass GitHub Actions ### Was this patch authored or co-authored using generative AI tooling? No Closes #43075 from LuciferYang/antlr4-4131. Authored-by: yangjie01 <yangjie01@baidu.com> Signed-off-by: Sean Owen <srowen@gmail.com>
### What changes were proposed in this pull request? This pr is aims upgrade `antlr4` from 4.9.3 to 4.13.1 ### Why are the changes needed? After 4.10, antlr4 is using Java 11 for the source code and the compiled .class files for the ANTLR tool. There are some bug fix and Improvements after 4.9.3: - antlr/antlr4#3399 - antlr/antlr4#1105 - antlr/antlr4#2788 - antlr/antlr4#3957 - antlr/antlr4#4394 The full release notes as follows: - https://github.com/antlr/antlr4/releases/tag/4.13.1 - https://github.com/antlr/antlr4/releases/tag/4.13.0 - https://github.com/antlr/antlr4/releases/tag/4.12.0 - https://github.com/antlr/antlr4/releases/tag/4.11.1 - https://github.com/antlr/antlr4/releases/tag/4.11.0 - https://github.com/antlr/antlr4/releases/tag/4.10.1 - https://github.com/antlr/antlr4/releases/tag/4.10 ### Does this PR introduce _any_ user-facing change? No ### How was this patch tested? Pass GitHub Actions ### Was this patch authored or co-authored using generative AI tooling? No Closes apache#43075 from LuciferYang/antlr4-4131. Authored-by: yangjie01 <yangjie01@baidu.com> Signed-off-by: Sean Owen <srowen@gmail.com> (cherry picked from commit 13cd291)
see http://stackoverflow.com/questions/31193527/stackoverflowerror-in-antlr4
The LexerATNSimulator should IMHO give up after a certain number of recursions before the StackOverflowError happens and spit out some information what is going on to help debug the grammer that causes the problem.
The text was updated successfully, but these errors were encountered: