From 5ce95be17439a8e510afc49df86c5b14eb6bbfd7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?D=C3=A1niel=20B=C3=A1tyai?= Date: Wed, 12 Aug 2020 20:50:48 +0200 Subject: [PATCH] Mark the lexical environments of running executable objects (#4133) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Fixes #4094. JerryScript-DCO-1.0-Signed-off-by: Dániel Bátyai daniel.batyai@h-lab.eu --- jerry-core/ecma/base/ecma-gc.c | 4 +-- .../es.next/regression-test-issue-4094.js | 25 +++++++++++++++++++ 2 files changed, 27 insertions(+), 2 deletions(-) create mode 100644 tests/jerry/es.next/regression-test-issue-4094.js diff --git a/jerry-core/ecma/base/ecma-gc.c b/jerry-core/ecma/base/ecma-gc.c index 60d0386f6..e2a26ce4d 100644 --- a/jerry-core/ecma/base/ecma-gc.c +++ b/jerry-core/ecma/base/ecma-gc.c @@ -425,6 +425,8 @@ ecma_gc_mark_executable_object (ecma_object_t *object_p) /**< object */ } } + ecma_gc_set_object_visited (executable_object_p->frame_ctx.lex_env_p); + if (!ECMA_EXECUTABLE_OBJECT_IS_SUSPENDED (executable_object_p->extended_object.u.class_prop.extra_info)) { /* All objects referenced by running executable objects are strong roots, @@ -432,8 +434,6 @@ ecma_gc_mark_executable_object (ecma_object_t *object_p) /**< object */ return; } - ecma_gc_set_object_visited (executable_object_p->frame_ctx.lex_env_p); - if (ecma_is_value_object (executable_object_p->frame_ctx.this_binding)) { ecma_gc_set_object_visited (ecma_get_object_from_value (executable_object_p->frame_ctx.this_binding)); diff --git a/tests/jerry/es.next/regression-test-issue-4094.js b/tests/jerry/es.next/regression-test-issue-4094.js new file mode 100644 index 000000000..5530a6ffd --- /dev/null +++ b/tests/jerry/es.next/regression-test-issue-4094.js @@ -0,0 +1,25 @@ +// Copyright JS Foundation and other contributors, http://js.foundation +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +function f() { + var o1 = {e:[]}; + var o2 = o1; + + async function g(a,b) { + await b; + o2 = 13.37; + } + g("a"); +} +f();