Open Toilal opened 8 years ago
Externalizing the stack would be the proper solution.
I have the same problem with classes generated from latest openapi generator https://github.com/OpenAPITools/openapi-generator/issues/12595
Hello. I don’t know if it is the good place or not.
I am trying to build in intellij a really large maven project containing around 300 maven modules and around 3 million java lines of code.
When building it, I have a StackOverflow error.
I post in the intellij forum my issue https://intellij-support.jetbrains.com/hc/en-us/community/posts/6608906517394-Build-large-maven-project-
After some research, Apparently it is coming from Lombok .
We have this stacktrace :
2022-07-14 00:42:47,242 [ 907730] INFO - #o.j.j.i.j.JavaBuilder - java.lang.StackOverflowError java.lang.RuntimeException: java.lang.StackOverflowError at jdk.compiler/com.sun.tools.javac.api.JavacTaskImpl.invocationHelper(JavacTaskImpl.java:168) at jdk.compiler/com.sun.tools.javac.api.JavacTaskImpl.doCall(JavacTaskImpl.java:100) at jdk.compiler/com.sun.tools.javac.api.JavacTaskImpl.call(JavacTaskImpl.java:94) at org.jetbrains.jps.javac.JavacMain.compile(JavacMain.java:238) at org.jetbrains.jps.incremental.java.JavaBuilder.lambda$compileJava$2(JavaBuilder.java:519) at org.jetbrains.jps.incremental.java.JavaBuilder.invokeJavac(JavaBuilder.java:565) at org.jetbrains.jps.incremental.java.JavaBuilder.compileJava(JavaBuilder.java:517) at org.jetbrains.jps.incremental.java.JavaBuilder.compile(JavaBuilder.java:360) at org.jetbrains.jps.incremental.java.JavaBuilder.doBuild(JavaBuilder.java:285) at org.jetbrains.jps.incremental.java.JavaBuilder.build(JavaBuilder.java:239) at org.jetbrains.jps.incremental.IncProjectBuilder.runModuleLevelBuilders(IncProjectBuilder.java:1519) at org.jetbrains.jps.incremental.IncProjectBuilder.runBuildersForChunk(IncProjectBuilder.java:1149) at org.jetbrains.jps.incremental.IncProjectBuilder.buildTargetsChunk(IncProjectBuilder.java:1299) at org.jetbrains.jps.incremental.IncProjectBuilder.buildChunkIfAffected(IncProjectBuilder.java:1114) at org.jetbrains.jps.incremental.IncProjectBuilder.buildChunks(IncProjectBuilder.java:885) at org.jetbrains.jps.incremental.IncProjectBuilder.runBuild(IncProjectBuilder.java:467) at org.jetbrains.jps.incremental.IncProjectBuilder.build(IncProjectBuilder.java:197) at org.jetbrains.jps.cmdline.BuildRunner.runBuild(BuildRunner.java:150) at org.jetbrains.jps.cmdline.BuildSession.runBuild(BuildSession.java:348) at org.jetbrains.jps.cmdline.BuildSession.run(BuildSession.java:175) at org.jetbrains.jps.cmdline.BuildMain$MyMessageHandler.lambda$channelRead0$0(BuildMain.java:218) at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1136) at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:635) at java.base/java.lang.Thread.run(Thread.java:833) Caused by: java.lang.StackOverflowError at java.base/java.lang.reflect.Field.get(Field.java:425) at lombok.core.AST.buildWithField0(AST.java:391) at lombok.core.AST.buildWithField(AST.java:292) at lombok.javac.JavacAST.drill(JavacAST.java:506) at lombok.javac.JavacAST.buildStatementOrExpression(JavacAST.java:476) at lombok.javac.JavacAST.buildTree(JavacAST.java:285) at lombok.javac.JavacAST.buildTree(JavacAST.java:1) at lombok.core.AST.buildWithField0(AST.java:394) at lombok.core.AST.buildWithField(AST.java:292) at lombok.javac.JavacAST.drill(JavacAST.java:506) at lombok.javac.JavacAST.buildStatementOrExpression(JavacAST.java:476) at lombok.javac.JavacAST.buildTree(JavacAST.java:285) at lombok.javac.JavacAST.buildTree(JavacAST.java:1) at lombok.core.AST.buildWithField0(AST.java:394) at lombok.core.AST.buildWithField(AST.java:292) at lombok.javac.JavacAST.drill(JavacAST.java:506) at lombok.javac.JavacAST.buildStatementOrExpression(JavacAST.java:476) at lombok.javac.JavacAST.buildTree(JavacAST.java:285) at lombok.javac.JavacAST.buildTree(JavacAST.java:1) at lombok.core.AST.buildWithField0(AST.java:394) at lombok.core.AST.buildWithField(AST.java:292) at lombok.javac.JavacAST.drill(JavacAST.java:506)
Do you have any idea how to resolve it ? Or Is there some work in Lombok to resolve this issue ? As said in the Intellij forum. With pure maven, I can build the project with no Issue.
How is going this issue ? Do you have any progress ?
Have you tried increasing stack size (-Xss
) in IDEA?
If it's building on maven and eclipse this means there is a difference between how lombok is called.
What I can suggest is to try my patch with maven but with limited stack size to reproduce this error and find a place where it happens and fix that place. Probably you have a very long statement in you code and this cause overflow.
I did several tests by increasing -Xss until -Xss12m. No changes. Which patch are you talking about ? There is probably a difference with intellij and the other tool. But which one, and by the way, I don’t think that we can change how intellij call lombok.
That's why I recommended replicating issue with maven where you can control java opts and lombok version. Patch I'm referring too https://github.com/projectlombok/lombok/pull/3213
How is going this issue ? Do you have any progress ? I'm also waiting for a response, idea 2023.1
I have the same problem with classes generated from latest openapi generator OpenAPITools/openapi-generator#12595
I have the same issue. Did you ever find a solution? Works fine building on OSX but fails on linux in github.
Update: This seemed to get it working-
MAVEN_OPTS: -Xss1024k
I have the same problem with classes generated from latest openapi generator OpenAPITools/openapi-generator#12595
I have the same issue. Did you ever find a solution? Works fine building on OSX but fails on linux in github.
Update: This seemed to get it working-
MAVEN_OPTS: -Xss1024k
The main reason for this issue is the file being too large, which causes a stack out of memory error during parsing. Until the bug is fixed, the core solutions are:
1、 split the excessively large file parsed using lombok. 2、increase Xss
Is there by chance a way to exclude target/generated-sources from being scanned by lombok? I use the maven-compiler-plugin with annotationProcessorPaths to run lombok. In my scenerio, the stack overflow error is when lombok parses the large files generated by openapi-generator-maven-plugin. These don't use lombok so i'd like to exclude them to prevent having to set the MVN xss size everywhere. Thanks.
@mikebm I have same problem and finally fixed the generator:
@janisz I am already on 6.0.0 of the generator, so the fix didn't appear to solve it. EDIT: Oh maybe your fix isn't in 6.0...
It's in 6.0.1 https://github.com/OpenAPITools/openapi-generator/releases/tag/v6.0.1 but it was only for okhttp if you sue different backend then it might not work.
It's in 6.0.1 https://github.com/OpenAPITools/openapi-generator/releases/tag/v6.0.1 but it was only for okhttp if you sue different backend then it might not work.
Yeah. Tried 6.6.0 and it didn't work for me. Thanks though. I think my question still stands. I don't need lombok processing my target folder, so if i can figure out how to do that, it would resolve my issue.
Agree, this will save some time as there is probably no point in scanning generated code.
Hello, I think I am facing the issue mentioned in this post.
[javac] An annotation processor threw an uncaught exception.
[javac] Consult the following stack trace for details.
[javac] java.lang.StackOverflowError
[javac] at lombok.javac.JavacAST.drill(JavacAST.java:506)
[javac] at lombok.javac.JavacAST.buildStatementOrExpression(JavacAST.java:476)
[javac] at lombok.javac.JavacAST.buildTree(JavacAST.java:285)
[javac] at lombok.javac.JavacAST.buildTree(JavacAST.java:1)
[javac] at lombok.core.AST.buildWithField0(AST.java:394)
[javac] at lombok.core.AST.buildWithField(AST.java:292)
The error does not specify which file it is failing at. I am trying to upgrade to JDK11 from JDK 8 and that requires upgrading to Lombok 1.18.x as Lombok 1.16.x does not work with JDK11. I have only 1 file in the code that is 638 lines long. That file does not have any Lombok annotations. Any suggestion on how to work around this issue ?
You can use #3213 to narrow down the error. If you have a long statements (a lot of dots: e.g. builder with lot of fileds). Split it into multiple smaller statements.
For me, by using x64 version of the JDK resolve the StackOverflowError error. I'm using JDK 11.
We could verfiy this too today. Breaking the long chained call down fixed the problem. But it took some time. OS: Windows Pro x64 JDK: amazonCorretto-21
Seeing the same issue. We're working with netflix DGS Framework and query building requires a very large number of chained operations.
Caused by: java.lang.StackOverflowError
at lombok.javac.JavacAST.buildStatementOrExpression(JavacAST.java:384)
at lombok.javac.JavacAST.buildTree(JavacAST.java:196)
I use DbSetup to define dataset for tests.
When trying to compile the project test classes (mvn clean test-compile), it crash with a StackOverflowError.
Increasing the JVM stack size using
-Xss4m
fix the issue, but it seems like a workaround to me and maybe Lombok could be enhanced to avoid this ?Here's an example of DbSetup classes that cause crash. As you can see, there's long fluent calls to define data, it's probably the huge call hierarchy that makes JavacAST eating up the stack ...
PS: I use Java 8 on Ubuntu, same issue on Windows.