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

StackOverflowError when OS has a lot of environment variables #700

Closed
extbe opened this issue Jul 24, 2020 · 2 comments · Fixed by #701
Closed

StackOverflowError when OS has a lot of environment variables #700

extbe opened this issue Jul 24, 2020 · 2 comments · Fixed by #701

Comments

@extbe
Copy link

extbe commented Jul 24, 2020

Hi!

Versions
config v1.4.0
Java 11.0.2

Description
I try to run my application on OS with about 700 environment variables. I have a config file with substitution test = ${ENV_VARIABLE} and next code to create Config:

Config conf = ConfigFactory.systemProperties()
                .withFallback(ConfigFactory.parseResources("test.conf"))
                .withFallback(ConfigFactory.systemEnvironment())
                .resolve();

Also I limit thread stack size to 210k using -Xss210k, so the application fails with an error (I skipped the rest of stack trace because it is about 900 lines long)

Exception in thread "main" java.lang.StackOverflowError
	at java.base/java.util.Collections$UnmodifiableCollection$1.<init>(Collections.java:1041)
	at java.base/java.util.Collections$UnmodifiableCollection.iterator(Collections.java:1041)
	at java.base/java.util.Collections$UnmodifiableCollection$1.<init>(Collections.java:1042)
	at java.base/java.util.Collections$UnmodifiableCollection.iterator(Collections.java:1041)
	at java.base/java.util.Collections$UnmodifiableCollection$1.<init>(Collections.java:1042)
	at java.base/java.util.Collections$UnmodifiableCollection.iterator(Collections.java:1041)
	at java.base/java.util.Collections$UnmodifiableCollection$1.<init>(Collections.java:1042)
	at java.base/java.util.Collections$UnmodifiableCollection.iterator(Collections.java:1041)

I noticed that if I remove the substitution or .withFallback(ConfigFactory.systemEnvironment()) then the application starts.

I debugged and found that in the ResolveContext each call to pushTrace or popTrace wraps cycleMarkers into another UnmodifiableSet (because the constructor does it), even though it's already an UnmodifiableSet.

havocp added a commit that referenced this issue Jul 24, 2020
This fixes #700 (Java is unhelpful and the Collections.unmodifiableList etc
methods don't check whether the thing is already wrapped).

These were just an assertion basically intended to find any accidental
modification of these collections, so not essential.
@extbe
Copy link
Author

extbe commented Sep 18, 2020

@havocp, is there anything else that has to be done before accepting the pull request? I've checked a modified version from the pull request and it seems that the issue has been solved.

@havocp
Copy link
Collaborator

havocp commented Sep 18, 2020

Nothing else afaik, thanks for testing. Just not a lot of active maintenance happening here unfortunately so things are slow.

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

Successfully merging a pull request may close this issue.

2 participants