From e681adce0584801f690e8f51220f35f94fbd913f Mon Sep 17 00:00:00 2001 From: Daniel Balla Date: Thu, 29 Oct 2020 10:50:37 +0100 Subject: [PATCH] Fix sweeping ecma_promise_value_thunk function objects (#4312) Fixes #4214 JerryScript-DCO-1.0-Signed-off-by: Daniel Balla dballa@inf.u-szeged.hu --- jerry-core/ecma/base/ecma-gc.c | 1 + .../es.next/regression-test-issue-4214.js | 19 +++++++++++++++++++ 2 files changed, 20 insertions(+) create mode 100644 tests/jerry/es.next/regression-test-issue-4214.js diff --git a/jerry-core/ecma/base/ecma-gc.c b/jerry-core/ecma/base/ecma-gc.c index c5687cda6..42fbc33ff 100644 --- a/jerry-core/ecma/base/ecma-gc.c +++ b/jerry-core/ecma/base/ecma-gc.c @@ -1319,6 +1319,7 @@ ecma_gc_free_object (ecma_object_t *object_p) /**< object to free */ case ECMA_NATIVE_HANDLER_VALUE_THUNK: case ECMA_NATIVE_HANDLER_VALUE_THROWER: { + ecma_free_value_if_not_object (((ecma_promise_value_thunk_t *) object_p)->value); ext_object_size = sizeof (ecma_promise_value_thunk_t); break; } diff --git a/tests/jerry/es.next/regression-test-issue-4214.js b/tests/jerry/es.next/regression-test-issue-4214.js new file mode 100644 index 000000000..302854e4e --- /dev/null +++ b/tests/jerry/es.next/regression-test-issue-4214.js @@ -0,0 +1,19 @@ +// 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. + +var called = false; Promise.resolve('d').finally((v) => called = true); + +function __checkAsync() { + assert(called); +}