Permalink
Show file tree
Hide file tree
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
Fixed frame allocation from an awaited frame.
njs_function_frame_save() is used to save the awaited frame when "await" instruction is encountered. The saving was done as a memcpy() of existing runtime frame. njs_function_frame_alloc() is used to alloc a new function frame, this function tries to use a spare preallocated memory from the previous frame first. Previously, this function might result in "use-after-free" when invoked from a restored frame saved with njs_function_frame_save(). Because njs_function_frame_save() left pointers to the spare memory of the original frame which may be already free when saved frame is restored. The fix is to erase fields for the spare memory from the saved frame. This closes #469 issue on Github.
- Loading branch information
Showing
3 changed files
with
31 additions
and
1 deletion.
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,26 @@ | ||
| /*--- | ||
| includes: [compareArray.js] | ||
| flags: [async] | ||
| ---*/ | ||
|
|
||
| let stages = []; | ||
|
|
||
| async function f(v) { | ||
| if (v == 1000) { | ||
| return; | ||
| } | ||
|
|
||
| stages.push(`f>${v}`); | ||
|
|
||
| await "X"; | ||
|
|
||
| await f(v + 1); | ||
|
|
||
| stages.push(`f<${v}`); | ||
| } | ||
|
|
||
| f(0) | ||
| .then(v => { | ||
| assert.sameValue(stages.length, 2000); | ||
| }) | ||
| .then($DONE, $DONE); |
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 |
|---|---|---|
|
|
@@ -6,7 +6,7 @@ flags: [async] | |
| let stages = []; | ||
|
|
||
| async function f(v) { | ||
| if (v == 3) { | ||
| if (v == 1000) { | ||
| return; | ||
| } | ||
|
|
||
|
|
||