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

[BUG] Stack overflow when adding large number of items to static ImmutableMap #2632

Closed
jchafik opened this issue Oct 28, 2020 · 3 comments
Closed

Comments

@jchafik
Copy link

jchafik commented Oct 28, 2020

Describe the bug
When including Lombok as a dependency, a stack overflow exception is thrown when attempting to initialize too many items in a static ImmutableMap.builder() property.

Locally, this fails when adding more than 436 items. However, the failure point would be platform dependent and based on the configured thread stack size (-Xss / XX:ThreadStackSize).

To Reproduce

package lombok;

import java.util.Map;
import com.google.common.collect.ImmutableMap;

public interface TestConstants
{
    public static final Map<String, String> TEST_STACK_OVERFLOW = ImmutableMap.<String, String>builder()
            .put("1", "")
            .put("2", "")
            ...
            .put("437", "")
            .build();
}

Stack trace excerpt

Caused by: java.lang.StackOverflowError
    at lombok.javac.JavacAST.drill (JavacAST.java:426)
    at lombok.javac.JavacAST.buildStatementOrExpression (JavacAST.java:392)
    at lombok.javac.JavacAST.buildTree (JavacAST.java:201)
    at lombok.javac.JavacAST.buildTree (JavacAST.java:1)
    at lombok.core.AST.buildWithCollection (AST.java:425)
    at lombok.core.AST.buildWithField0 (AST.java:399)
    at lombok.core.AST.buildWithField (AST.java:292)
    at lombok.javac.JavacAST.drill (JavacAST.java:426)
    at lombok.javac.JavacAST.buildStatementOrExpression (JavacAST.java:392)
    at lombok.javac.JavacAST.buildTree (JavacAST.java:201)
    at lombok.javac.JavacAST.buildTree (JavacAST.java:1)
    at lombok.core.AST.buildWithField0 (AST.java:394)
    at lombok.core.AST.buildWithField (AST.java:292)

Expected behavior
The class should compile without error (as it does when excluding Lombok as a dependency)

Version info (please complete the following information):

  • Lombok version 1.18.16
  • javac running openjdk 11.0.9 2020-10-20
  • Google Guava 30.0-jre
@Rawi01
Copy link
Collaborator

Rawi01 commented Oct 28, 2020

Thanks for reporting, this is a duplicate of #2453, #1171, #1118. Replacing these recursive function calls is not that easy...

@rspilker
Copy link
Collaborator

Well, it might be by externalizing the stack. I'll have a look at it.

@rspilker
Copy link
Collaborator

I'm closing all duplicates of #1118

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

3 participants