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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

Stack overflow in KernelHost.run() #778

Closed
2 of 4 tasks
ddinu opened this issue Sep 13, 2019 · 0 comments 路 Fixed by #780
Closed
2 of 4 tasks

Stack overflow in KernelHost.run() #778

ddinu opened this issue Sep 13, 2019 · 0 comments 路 Fixed by #780
Labels
bug This issue is a bug. needs-triage This issue or PR still needs to be triaged.

Comments

@ddinu
Copy link
Contributor

ddinu commented Sep 13, 2019

馃悰 Bug Report

Affected Languages

  • TypeScript or Javascript
  • Python
  • Java
  • .NET (C#, F#, ...)

General Information

  • JSII Version: master
  • Platform: OSX, Amazon Linux

What is the problem?

I am getting a stack overflow error with large Java-based CDK CloudFormation stacks. This seems to be happening because the KernelHost.run() and KernelHost.processRequest() functions are mutually-recursive through the next callback.

RangeError: Maximum call stack size exceeded
    at KernelHost.processRequest (/tmp/jsii-java-runtime4513439031470941034/jsii-runtime.js:6063:18)
    at KernelHost.run (/tmp/jsii-java-runtime4513439031470941034/jsii-runtime.js:5970:14)
    at processRequest (/tmp/jsii-java-runtime4513439031470941034/jsii-runtime.js:5970:45)
    at KernelHost.processRequest (/tmp/jsii-java-runtime4513439031470941034/jsii-runtime.js:6066:16)
    at KernelHost.run (/tmp/jsii-java-runtime4513439031470941034/jsii-runtime.js:5970:14)
    at processRequest (/tmp/jsii-java-runtime4513439031470941034/jsii-runtime.js:5970:45)
    at KernelHost.processRequest (/tmp/jsii-java-runtime4513439031470941034/jsii-runtime.js:6066:16)
    at KernelHost.run (/tmp/jsii-java-runtime4513439031470941034/jsii-runtime.js:5970:14)
    at processRequest (/tmp/jsii-java-runtime4513439031470941034/jsii-runtime.js:5970:45)
    at KernelHost.processRequest (/tmp/jsii-java-runtime4513439031470941034/jsii-runtime.js:6066:16)
    at software.amazon.jsii.JsiiRuntime.processErrorResponse(JsiiRuntime.java:112)
    at software.amazon.jsii.JsiiRuntime.requestResponse(JsiiRuntime.java:84)
    at software.amazon.jsii.JsiiClient.callMethod(JsiiClient.java:185)
    at software.amazon.jsii.JsiiObject.jsiiCall(JsiiObject.java:57)
    [our stack...]

I will submit a PR with a test and fix shortly.

@ddinu ddinu added bug This issue is a bug. needs-triage This issue or PR still needs to be triaged. labels Sep 13, 2019
ddinu pushed a commit to ddinu/jsii that referenced this issue Sep 13, 2019
ddinu pushed a commit to ddinu/jsii that referenced this issue Sep 13, 2019
ddinu pushed a commit to ddinu/jsii that referenced this issue Sep 14, 2019
RomainMuller pushed a commit that referenced this issue Sep 16, 2019
Fixes #778. This PR eliminates the mutual recursion between `KernelHost.run()` and `KernelHost.processRequest()` by scheduling the recursive `KernelHost.run()` call to run on the next iteration of the event loop.

The code change has been tested as follows:

- by running the stress-test script with and without the change to confirm that the crash occurs without the change and does not occur with the change;
- by running the unit tests to confirm that behavior is consistent;
- by synthesizing our internal CDK stack and confirming that the crash does not occur and that resources are generated correctly.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug This issue is a bug. needs-triage This issue or PR still needs to be triaged.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant