-
Notifications
You must be signed in to change notification settings - Fork 246
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(kernel): stack overflow in KernelHost.run() (#780)
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.
- Loading branch information
1 parent
7b3b059
commit 41a8c2f
Showing
3 changed files
with
32 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
import { InputOutput, Input, Output } from "../lib/in-out"; | ||
import { KernelHost } from "../lib/host"; | ||
|
||
const requestCount = 250000; | ||
|
||
class FakeInputOutput extends InputOutput { | ||
debug = false; | ||
private count: number = 0; | ||
|
||
write(_: Output) { } | ||
|
||
read(): Input | undefined { | ||
if(this.count == requestCount) { | ||
return undefined; | ||
} | ||
|
||
++this.count; | ||
return { api: 'stats' }; | ||
} | ||
} | ||
|
||
const inout = new FakeInputOutput(); | ||
const host = new KernelHost(inout, { debug: false, noStack: false }); | ||
host.run(); | ||
|
||
console.info("jsii-runtime stress test succeeded"); |