-
Notifications
You must be signed in to change notification settings - Fork 3.9k
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
core: Stack with many resources combined with aspects results in StackOverflowErrors #26517
Comments
Thanks for reporting, might be best in the |
Hi @Saberos can you confirm why you can't use |
@mrgrain just to ensure we're on the same page, the default stack size limit in the JVM seems to be commonly 1-2MB. It isn't so much that the program is incredibly memory expensive, just that aspects appear to be implemented using recursion which can exceed the stack size limit. Increasing the limit is mostly inconvenient because we have to consider/manage the In my opinion the limit is also hit fairly easily, the scenarios do not seem that extreme. With |
Thanks for the clarification @Saberos ! I agree having to consider Depending on your scenario, you can also apply Aspects more locally on specific parts of the Construct tree, not just the root. Assigned |
A workaround for us for now was to refactor an aspect to set IAM permission boundaries to the CDK construct that has been introduced since we set that up. I do not know if that eliminated the recursion of just moves it to Node.js where the stack limit is higher, but for now it is sufficient for us to stay under the limit. |
We ran into the exact same problem when using an Aspect as a workaround for the issue described in #19114. Like in the scenario of the OP our stack is also not very big, so this issue came a little unexpected. Setting a higher |
I have a similar problem with a even more weird behavior.
IF i print the construct Id, the issue persists
But, if i print getAllContext the issue got fixed
|
Describe the bug
When using aspects in combination with stacks with a large number of resources we are running into StackOverflowError during synthesis in our Java CDK applications. The issue is somewhat system dependent as the default limits enforced by the JVM change depending on available system resources (and probably JVM vendor).
Expected Behavior
Stacks with many resources with aspects to synthesize successfully.
Current Behavior
Synthesis fails on a StackOverFlowError.
Reproduction Steps
I have managed to reproduce the issue in a minimal project, available here: https://github.com/Saberos/cdk-aspect-stackoverflowerror
cdk synth
produces the error while the aspect is present. Once the aspect is removed synthesis completes as expected. Note that the stack size has been forcibly limited in thecdk.json
to ensure the issue is reproducible independent of the system. Without the-Xss
flag the issue may or may not appear on the system. Increasing the number of resources in the stack or the number of aspects should allow the issue to be reproduced on any system even without using this flag.Possible Solution
No response
Additional Information/Context
No response
CDK CLI Version
2.86.0
Framework Version
2.86.0
Node.js Version
v18.12.1
OS
macOS Ventura 13.2.1
Language
Java
Language Version
Corretto-17.0.7.7.1
Other information
The StackOverflowError stacktrace:
The text was updated successfully, but these errors were encountered: