INRIA / spoon

Spoon is a metaprogramming library to analyze and transform Java source code. :spoon: is made with :heart:, :beers: and :sparkles:. It parses source files to build a well-designed AST with powerful analysis and transformation API.
http://spoon.gforge.inria.fr/
Other
1.75k stars 351 forks source link

Spoon throws StackOverflowError #3570

Open darius-sas opened 4 years ago

darius-sas commented 4 years ago

Hello, I wanted to report another common issue I am encountering during my research. For instance, while parsing https://github.com/stanfordnlp/CoreNLP/commit/b95cd18ce7e865bcb7cc3f3ade2c2e08295c6d6f using Spoon as a library, I get this error:

16:56:41 [main] DEBUG Could not find declaration for variable Language at (/home/fenn/data/repos/CoreNLP/src/edu/stanford/nlp/pipeline/CoreNLPProtos.java:161).
16:56:41 [main] DEBUG Could not find declaration for variable Sentiment at (/home/fenn/data/repos/CoreNLP/src/edu/stanford/nlp/pipeline/CoreNLPProtos.java:288).
16:56:41 [main] DEBUG Could not find declaration for variable NaturalLogicRelation at (/home/fenn/data/repos/CoreNLP/src/edu/stanford/nlp/pipeline/CoreNLPProtos.java:433).
16:56:48 [main] DEBUG Freed memory of version: 1-b95cd18ce7e865bcb7cc3f3ade2c2e08295c6d6f
Exception in thread "main" java.lang.StackOverflowError
    at spoon.reflect.visitor.CtScanner.visitCtBinaryOperator(CtScanner.java:287)
    at spoon.support.reflect.code.CtBinaryOperatorImpl.accept(CtBinaryOperatorImpl.java:34)
    at spoon.reflect.visitor.CtScanner.scan(CtScanner.java:177)
    at spoon.reflect.visitor.AstParentConsistencyChecker.scan(AstParentConsistencyChecker.java:33)
    at spoon.reflect.visitor.CtScanner.scan(CtScanner.java:169)
    at spoon.reflect.visitor.CtScanner.visitCtBinaryOperator(CtScanner.java:290)
    at spoon.support.reflect.code.CtBinaryOperatorImpl.accept(CtBinaryOperatorImpl.java:34)
    at spoon.reflect.visitor.CtScanner.scan(CtScanner.java:177)
    at spoon.reflect.visitor.AstParentConsistencyChecker.scan(AstParentConsistencyChecker.java:33)
    at spoon.reflect.visitor.CtScanner.scan(CtScanner.java:169)
    at spoon.reflect.visitor.CtScanner.visitCtBinaryOperator(CtScanner.java:290)
    at spoon.support.reflect.code.CtBinaryOperatorImpl.accept(CtBinaryOperatorImpl.java:34)
    at spoon.reflect.visitor.CtScanner.scan(CtScanner.java:177)
[...]

Environment:

environment.setEncoding(StandardCharsets.UTF_8);
environment.disableConsistencyChecks();
environment.setComplianceLevel(9);
environment.setIgnoreDuplicateDeclarations(true);
environment.setCommentEnabled(false);
environment.setNoClasspath(true);
environment.setShouldCompile(false);

Java:

openjdk version "14.0.1" 2020-04-14
OpenJDK Runtime Environment (build 14.0.1+7-Ubuntu-1ubuntu1)
OpenJDK 64-Bit Server VM (build 14.0.1+7-Ubuntu-1ubuntu1, mixed mode, sharing)

Thank you for your help.

monperrus commented 4 years ago

Thanks for the bug report. Would you be able to write a failing test case in a pull-request? That would be super useful.