Skip to content

Commit bac7ee3

Browse files
authored
Fix gc of async destructuring assignments of strings (#5126)
This fixes #5089 When garbage collection is running on a paused async function that includes destructuring assignments of strings, the string can be a direct string, and not an object, which cannot be marked as visited, as it does not have a visited flag. JerryScript-DCO-1.0-Signed-off-by: Máté Tokodi [email protected]
1 parent 52debe8 commit bac7ee3

File tree

2 files changed

+32
-1
lines changed

2 files changed

+32
-1
lines changed

jerry-core/ecma/base/ecma-gc.c

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -742,7 +742,11 @@ ecma_gc_mark_executable_object (ecma_object_t *object_p) /**< object */
742742

743743
do
744744
{
745-
ecma_gc_set_object_visited (ecma_get_object_from_value (*(--context_top_p)));
745+
--context_top_p;
746+
if (ecma_is_value_object (*context_top_p))
747+
{
748+
ecma_gc_set_object_visited (ecma_get_object_from_value (*context_top_p));
749+
}
746750
} while (context_top_p > last_item_p);
747751

748752
continue;
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
// Copyright JS Foundation and other contributors, http://js.foundation
2+
//
3+
// Licensed under the Apache License, Version 2.0 (the "License");
4+
// you may not use this file except in compliance with the License.
5+
// You may obtain a copy of the License at
6+
//
7+
// http://www.apache.org/licenses/LICENSE-2.0
8+
//
9+
// Unless required by applicable law or agreed to in writing, software
10+
// distributed under the License is distributed on an "AS IS" BASIS
11+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
// See the License for the specific language governing permissions and
13+
// limitations under the License.
14+
15+
async function test1() {
16+
var a;
17+
({k: a = await 1} = "XY");
18+
}
19+
test1();
20+
gc();
21+
22+
async function test2() {
23+
var a;
24+
[a = await 1] = "";
25+
}
26+
test2();
27+
gc();

0 commit comments

Comments
 (0)