From e057e038322650560772324c5015785d46f718ff Mon Sep 17 00:00:00 2001 From: wuxiesaber Date: Sat, 21 Dec 2024 19:53:12 +0800 Subject: [PATCH 1/5] fix no checking of stack overflow in proxy Issue: https://gitee.com/openharmony/arkcompiler_ets_runtime/issues/IBCUJM Signed-off-by: wuxiesaber Change-Id: I6ac963ee4ba6f870d1288a95c42f0415af95b27f --- ecmascript/stubs/runtime_stubs-inl.h | 1 + test/moduletest/BUILD.gn | 3 ++ test/moduletest/proxyrelease/BUILD.gn | 18 ++++++++++ .../moduletest/proxyrelease/expect_output.txt | 14 ++++++++ test/moduletest/proxyrelease/proxyrelease.js | 34 +++++++++++++++++++ 5 files changed, 70 insertions(+) create mode 100644 test/moduletest/proxyrelease/BUILD.gn create mode 100644 test/moduletest/proxyrelease/expect_output.txt create mode 100644 test/moduletest/proxyrelease/proxyrelease.js diff --git a/ecmascript/stubs/runtime_stubs-inl.h b/ecmascript/stubs/runtime_stubs-inl.h index 7e2a4aec04..1a5132746f 100644 --- a/ecmascript/stubs/runtime_stubs-inl.h +++ b/ecmascript/stubs/runtime_stubs-inl.h @@ -2619,6 +2619,7 @@ JSTaggedValue RuntimeStubs::RuntimeOptConstructProxy(JSThread *thread, JSHandle< JSHandle newTgt, JSHandle preArgs, JSHandle args) { + STACK_LIMIT_CHECK(thread, JSTaggedValue::Exception()); // step 1 ~ 4 get ProxyHandler and ProxyTarget JSHandle handler(thread, ctor->GetHandler()); if (handler->IsNull()) { diff --git a/test/moduletest/BUILD.gn b/test/moduletest/BUILD.gn index 84e50ff1c3..46d9a625d7 100644 --- a/test/moduletest/BUILD.gn +++ b/test/moduletest/BUILD.gn @@ -189,6 +189,7 @@ group("ark_js_moduletest") { "multiconstpoolconstructor", "multiconstpoolfunc", "multiconstpoolobj", + "proxyrelease", ] foreach(test, release_test_list) { @@ -345,6 +346,7 @@ group("ark_asm_test") { "multiconstpoolconstructor", "multiconstpoolfunc", "multiconstpoolobj", + "proxyrelease", ] foreach(test, release_test_list) { @@ -476,6 +478,7 @@ group("ark_asm_single_step_test") { "multiconstpoolconstructor", "multiconstpoolfunc", "multiconstpoolobj", + "proxyrelease", ] foreach(test, release_test_list) { diff --git a/test/moduletest/proxyrelease/BUILD.gn b/test/moduletest/proxyrelease/BUILD.gn new file mode 100644 index 0000000000..3b0f1d906a --- /dev/null +++ b/test/moduletest/proxyrelease/BUILD.gn @@ -0,0 +1,18 @@ +# Copyright (c) 2024 Huawei Device Co., Ltd. +# 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. + +import("//arkcompiler/ets_runtime/test/test_helper.gni") + +host_moduletest_assert_action("proxyrelease") { + deps = [] +} diff --git a/test/moduletest/proxyrelease/expect_output.txt b/test/moduletest/proxyrelease/expect_output.txt new file mode 100644 index 0000000000..afc93c05cf --- /dev/null +++ b/test/moduletest/proxyrelease/expect_output.txt @@ -0,0 +1,14 @@ +# Copyright (c) 2024 Huawei Device Co., Ltd. +# 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. + +RangeError: Stack overflow! diff --git a/test/moduletest/proxyrelease/proxyrelease.js b/test/moduletest/proxyrelease/proxyrelease.js new file mode 100644 index 0000000000..e59a33292a --- /dev/null +++ b/test/moduletest/proxyrelease/proxyrelease.js @@ -0,0 +1,34 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * 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. + */ + +/* + * @tc.name:proxy + * @tc.desc:test proxy + * @tc.type: FUNC + * @tc.require: issueIBCUJM + */ + +// This case aims to test if there's stack-overflow checking in RuntimeOptConstructProxy +{ + let v0 = new Proxy(function () {}, {}); + for (let v1 = 0; v1 < 10000; v1++) { + v0 = new Proxy(v0, {}); + } + try { + new v0(0); + } catch (error) { + print(error); + } +} -- Gitee From 03d9bba198ff3209d81a1690ebd0da416d557375 Mon Sep 17 00:00:00 2001 From: wuxiesaber Date: Thu, 26 Dec 2024 19:12:51 +0800 Subject: [PATCH 2/5] add taggedOject check in GetIterator https://gitee.com/openharmony/arkcompiler_ets_runtime/issues/IBDZ1R Signed-off-by: wuxiesaber Change-Id: Ic82f8fb67a858e79a985ef687b5d0b8476f006dd --- ecmascript/compiler/interpreter_stub.cpp | 3 ++ ecmascript/compiler/stub_builder.cpp | 18 +++++++++++ ecmascript/message_string.h | 3 +- test/moduletest/BUILD.gn | 3 ++ test/moduletest/getiterator/BUILD.gn | 18 +++++++++++ test/moduletest/getiterator/expect_output.txt | 14 ++++++++ test/moduletest/getiterator/getiterator.js | 32 +++++++++++++++++++ 7 files changed, 90 insertions(+), 1 deletion(-) create mode 100644 test/moduletest/getiterator/BUILD.gn create mode 100644 test/moduletest/getiterator/expect_output.txt create mode 100644 test/moduletest/getiterator/getiterator.js diff --git a/ecmascript/compiler/interpreter_stub.cpp b/ecmascript/compiler/interpreter_stub.cpp index d3c11c2baa..c77eb056f5 100644 --- a/ecmascript/compiler/interpreter_stub.cpp +++ b/ecmascript/compiler/interpreter_stub.cpp @@ -1319,6 +1319,7 @@ DECLARE_ASM_HANDLER(HandleSupercallspreadImm8V8) Label ctorIsConstructor(env); Label threadCheck(env); Label isException(env); + Label noException(env); Branch(TaggedIsHeapObject(superCtor), &ctorIsHeapObject, &slowPath); Bind(&ctorIsHeapObject); @@ -1337,6 +1338,8 @@ DECLARE_ASM_HANDLER(HandleSupercallspreadImm8V8) Bind(&ctorNotBase); GateRef argvLen = Load(VariableType::INT32(), array, IntPtr(JSArray::LENGTH_OFFSET)); GateRef srcElements = GetCallSpreadArgs(glue, array, callback); + Branch(TaggedIsException(srcElements), &isException, &noException); + Bind(&noException); GateRef jumpSize = IntPtr(-BytecodeInstruction::Size(BytecodeInstruction::Format::IMM8_V8)); METHOD_ENTRY_ENV_DEFINED(superCtor); GateRef elementsPtr = PtrAdd(srcElements, IntPtr(TaggedArray::DATA_OFFSET)); diff --git a/ecmascript/compiler/stub_builder.cpp b/ecmascript/compiler/stub_builder.cpp index 16db546c8a..c9a4bca9e0 100644 --- a/ecmascript/compiler/stub_builder.cpp +++ b/ecmascript/compiler/stub_builder.cpp @@ -6666,6 +6666,7 @@ GateRef StubBuilder::GetIterator(GateRef glue, GateRef obj, ProfileOperation cal Label noPendingException(env); Label isHeapObject(env); Label objIsCallable(env); + Label throwError(env); GateRef glueGlobalEnvOffset = IntPtr(JSThread::GlueData::GetGlueGlobalEnvOffset(env->Is32Bit())); GateRef glueGlobalEnv = Load(VariableType::NATIVE_POINTER(), glue, glueGlobalEnvOffset); @@ -6686,6 +6687,14 @@ GateRef StubBuilder::GetIterator(GateRef glue, GateRef obj, ProfileOperation cal { result = JSCallDispatch(glue, *result, Int32(0), 0, Circuit::NullGate(), JSCallMode::CALL_GETTER, { obj }, ProfileOperation()); + Branch(TaggedIsHeapObject(*result), &exit, &throwError); + } + + Bind(&throwError); + { + GateRef taggedId = Int32(GET_MESSAGE_STRING_ID(IterNotObject)); + CallRuntime(glue, RTSTUB_ID(ThrowTypeError), { IntToTaggedInt(taggedId) }); + result = Exception(); Jump(&exit); } @@ -7973,8 +7982,17 @@ GateRef StubBuilder::GetCallSpreadArgs(GateRef glue, GateRef array, ProfileOpera Label fastPath(env); Label noCopyPath(env); Label exit(env); + Label noException(env); + Label isException(env); GateRef itor = GetIterator(glue, array, callBack); + Branch(TaggedIsException(itor), &isException, &noException); + Bind(&isException); + { + result = Exception(); + Jump(&exit); + } + Bind(&noException); GateRef iterHClass = LoadHClass(itor); GateRef isJSArrayIter = Int32Equal(GetObjectType(iterHClass), Int32(static_cast(JSType::JS_ARRAY_ITERATOR))); diff --git a/ecmascript/message_string.h b/ecmascript/message_string.h index bc42677bf1..ff1b4322fa 100644 --- a/ecmascript/message_string.h +++ b/ecmascript/message_string.h @@ -55,7 +55,8 @@ namespace panda::ecmascript { V(CanNotConvertUnknowObject, "Cannot convert a Unknown object value to a JSObject") \ V(CanNotConvertNotValidObject, "Obj is not a valid object") \ V(CanNotConvertContainerObject, "Can not delete property in Container Object") \ - V(InvalidStringLength, "Invalid string length") + V(InvalidStringLength, "Invalid string length") \ + V(IterNotObject, "JSIterator::GetIterator: iter is not object") #define DEBUG_CHECK_MESSAGE_STRING_LIST(V) \ V(IsCallable) \ diff --git a/test/moduletest/BUILD.gn b/test/moduletest/BUILD.gn index 46d9a625d7..af920da349 100644 --- a/test/moduletest/BUILD.gn +++ b/test/moduletest/BUILD.gn @@ -171,6 +171,7 @@ group("ark_js_moduletest") { "sharedcheck", "definesendableclass", "sendablecontext", + "getiterator", ] deps = [] @@ -327,6 +328,7 @@ group("ark_asm_test") { "sharedcheck", "definesendableclass", "sendablecontext", + "getiterator", ] deps = [] @@ -460,6 +462,7 @@ group("ark_asm_single_step_test") { "sharedcheck", "definesendableclass", "sendablecontext", + "getiterator", ] deps = [] diff --git a/test/moduletest/getiterator/BUILD.gn b/test/moduletest/getiterator/BUILD.gn new file mode 100644 index 0000000000..c607331088 --- /dev/null +++ b/test/moduletest/getiterator/BUILD.gn @@ -0,0 +1,18 @@ +# Copyright (c) 2025 Huawei Device Co., Ltd. +# 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. + +import("//arkcompiler/ets_runtime/test/test_helper.gni") + +host_moduletest_action("getiterator") { + deps = [] +} diff --git a/test/moduletest/getiterator/expect_output.txt b/test/moduletest/getiterator/expect_output.txt new file mode 100644 index 0000000000..65a51cc345 --- /dev/null +++ b/test/moduletest/getiterator/expect_output.txt @@ -0,0 +1,14 @@ +# Copyright (c) 2025 Huawei Device Co., Ltd. +# 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. + +TypeError: JSIterator::GetIterator: iter is not object diff --git a/test/moduletest/getiterator/getiterator.js b/test/moduletest/getiterator/getiterator.js new file mode 100644 index 0000000000..8b625d6ef9 --- /dev/null +++ b/test/moduletest/getiterator/getiterator.js @@ -0,0 +1,32 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * 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. + */ + +/* + * @tc.name:getiterator + * @tc.desc:test StubBuilder::GetIterator + * @tc.type: FUNC + * @tc.require: issueIBDZ1R + */ + +// This case aims to test the logic which check the undefined result of GetIterator. +{ + class c2 extends Object {} + Array.prototype[Symbol.iterator] = function () {}; + try { + let myC2 = new c2(); + } catch (error) { + print(error); + } +} -- Gitee From 9df8c783d6681302befc8515bec13348d4f8f044 Mon Sep 17 00:00:00 2001 From: wuxiesaber Date: Sat, 4 Jan 2025 23:16:12 +0800 Subject: [PATCH 3/5] fix return of GetDeletedElementsAt Issue: https://gitee.com/openharmony/arkcompiler_ets_runtime/issues/IBFP2E Signed-off-by: wuxiesaber Change-Id: Ia18bcef781ff04db2d911cf3aa6ec465ee75af42 --- .../linked_hashtable_stub_builder.cpp | 9 ++++- test/moduletest/BUILD.gn | 3 ++ test/moduletest/getdeletedelementsat/BUILD.gn | 18 ++++++++++ .../getdeletedelementsat/expect_output.txt | 14 ++++++++ .../getdeletedelementsat.js | 33 +++++++++++++++++++ 5 files changed, 76 insertions(+), 1 deletion(-) create mode 100644 test/moduletest/getdeletedelementsat/BUILD.gn create mode 100644 test/moduletest/getdeletedelementsat/expect_output.txt create mode 100644 test/moduletest/getdeletedelementsat/getdeletedelementsat.js diff --git a/ecmascript/compiler/builtins/linked_hashtable_stub_builder.cpp b/ecmascript/compiler/builtins/linked_hashtable_stub_builder.cpp index 2404124e5e..20171c30a4 100644 --- a/ecmascript/compiler/builtins/linked_hashtable_stub_builder.cpp +++ b/ecmascript/compiler/builtins/linked_hashtable_stub_builder.cpp @@ -346,8 +346,15 @@ GateRef LinkedHashTableStubBuilder:: Label loopEnd(env); Label next(env); Label loopExit(env); + Label noNumberOfDeletedElements(env); + + Branch(Int32Equal(GetNumberOfDeletedElements(linkedTable), Int32(-1)), &noNumberOfDeletedElements, &loopHead); + Bind(&noNumberOfDeletedElements); + { + res = entry; + Jump(&exit); + } - Jump(&loopHead); LoopBegin(&loopHead); { Branch(Int32GreaterThanOrEqual(*currentEntry, Int32(0)), &next, &loopExit); diff --git a/test/moduletest/BUILD.gn b/test/moduletest/BUILD.gn index af920da349..f28d42394c 100644 --- a/test/moduletest/BUILD.gn +++ b/test/moduletest/BUILD.gn @@ -84,6 +84,7 @@ group("ark_js_moduletest") { "funcprotochangeobjectandnew", "functionapply", "generator", + "getdeletedelementsat", "getpropertybyindex", "getunmappedargs", "global", @@ -267,6 +268,7 @@ group("ark_asm_test") { "funcprotochangeobjectandnew", "functionapply", "generator", + "getdeletedelementsat", "getunmappedargs", "global", "globalaccessor", @@ -410,6 +412,7 @@ group("ark_asm_single_step_test") { "funcprotochangeobjectandnew", "functionapply", "generator", + "getdeletedelementsat", "getunmappedargs", "global", "globalaccessor", diff --git a/test/moduletest/getdeletedelementsat/BUILD.gn b/test/moduletest/getdeletedelementsat/BUILD.gn new file mode 100644 index 0000000000..1e8c7000a9 --- /dev/null +++ b/test/moduletest/getdeletedelementsat/BUILD.gn @@ -0,0 +1,18 @@ +# Copyright (c) 2025 Huawei Device Co., Ltd. +# 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. + +import("//arkcompiler/ets_runtime/test/test_helper.gni") + +host_moduletest_action("getdeletedelementsat") { + deps = [] +} diff --git a/test/moduletest/getdeletedelementsat/expect_output.txt b/test/moduletest/getdeletedelementsat/expect_output.txt new file mode 100644 index 0000000000..48c2f6e60a --- /dev/null +++ b/test/moduletest/getdeletedelementsat/expect_output.txt @@ -0,0 +1,14 @@ +# Copyright (c) 2025 Huawei Device Co., Ltd. +# 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. + +Test runs successfully! diff --git a/test/moduletest/getdeletedelementsat/getdeletedelementsat.js b/test/moduletest/getdeletedelementsat/getdeletedelementsat.js new file mode 100644 index 0000000000..bdbfed988c --- /dev/null +++ b/test/moduletest/getdeletedelementsat/getdeletedelementsat.js @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * 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. + */ + +/* + * @tc.name:getdeletedelementsat + * @tc.desc:test GetDeletedElementsAt + * @tc.type: FUNC + * @tc.require: issueIBFP2E + */ + +// This case aims to check return value of GetDeletedElementsAt +{ + let map1 = new Map(); + map1.set(0, 1); + map1.set(1, 2); + map1.set(2, 3); + map1.set(3, 4); + map1.delete(0); + map1.forEach(function () { map1.clear() }); + print("Test runs successfully!"); +} -- Gitee From f40dbb6ef925eeac2d82d9c9ef878a93ae6c4c4c Mon Sep 17 00:00:00 2001 From: wuxiesaber Date: Tue, 14 Jan 2025 19:10:49 +0800 Subject: [PATCH 4/5] fix stack overflow of regex_match Issue: https://gitee.com/openharmony/arkcompiler_ets_runtime/issues/IBHSYW Signed-off-by: wuxiesaber Change-Id: I61cff5e9dbfd4aeb4ff6484a659d2237eb7c3368 --- ecmascript/js_date_time_format.cpp | 20 ++++++------------- ecmascript/js_date_time_format.h | 2 -- test/moduletest/datetimezone/datetimezone.js | 9 ++++++++- .../moduletest/datetimezone/expect_output.txt | 1 + test/moduletest/proxyrelease/BUILD.gn | 2 +- 5 files changed, 16 insertions(+), 18 deletions(-) diff --git a/ecmascript/js_date_time_format.cpp b/ecmascript/js_date_time_format.cpp index 4c4eb0e3e3..e15e703e36 100644 --- a/ecmascript/js_date_time_format.cpp +++ b/ecmascript/js_date_time_format.cpp @@ -1521,31 +1521,23 @@ std::string JSDateTimeFormat::ToTitleCaseFunction(const std::string &input) return result; } -bool JSDateTimeFormat::IsValidTimeZoneInput(const std::string &input) -{ - std::regex r("[a-zA-Z_\\-/]*"); - bool isValid = regex_match(input, r); - return isValid; -} - std::string JSDateTimeFormat::ToTitleCaseTimezonePosition(const std::string &input) { - if (!IsValidTimeZoneInput(input)) { - return std::string(); - } std::vector titleEntry; std::vector charEntry; - int32_t leftPosition = 0; - int32_t titleLength = 0; - for (int32_t i = 0; i < static_cast(input.length()); i++) { + uint32_t leftPosition = 0; + uint32_t titleLength = 0; + for (size_t i = 0; i < input.length(); i++) { if (input[i] == '_' || input[i] == '-' || input[i] == '/') { std::string s(1, input[i]); charEntry.emplace_back(s); titleLength = i - leftPosition; titleEntry.emplace_back(input.substr(leftPosition, titleLength)); leftPosition = i + 1; - } else { + } else if (JSLocale::IsAsciiAlpha(input[i]) || input[i] == '\\') { continue; + } else { + return std::string(); } } titleEntry.emplace_back(input.substr(leftPosition, input.length() - leftPosition)); diff --git a/ecmascript/js_date_time_format.h b/ecmascript/js_date_time_format.h index 08aedfc43a..48a41543a8 100644 --- a/ecmascript/js_date_time_format.h +++ b/ecmascript/js_date_time_format.h @@ -209,8 +209,6 @@ private: static std::string ToTitleCaseFunction(const std::string &input); - static bool IsValidTimeZoneInput(const std::string &input); - static JSHandle ToValueString(JSThread *thread, Value value); static icu::FormattedDateInterval ConstructDTFRange(JSThread *thread, const JSHandle &dtf, diff --git a/test/moduletest/datetimezone/datetimezone.js b/test/moduletest/datetimezone/datetimezone.js index 85223757b1..e589c66e01 100755 --- a/test/moduletest/datetimezone/datetimezone.js +++ b/test/moduletest/datetimezone/datetimezone.js @@ -16,4 +16,11 @@ try { new Intl.DateTimeFormat("en" , { timeZone: "US/Alaska0" }); } catch (e) { print(e instanceof RangeError); -} \ No newline at end of file +} + +// This case aims to check stack overflow while timeZone is a long string +try { + new Intl.DateTimeFormat("en", {timeZone: Array(0x8000).join("a")}); +} catch (e) { + print(e); +} diff --git a/test/moduletest/datetimezone/expect_output.txt b/test/moduletest/datetimezone/expect_output.txt index ce415d321a..355befa022 100755 --- a/test/moduletest/datetimezone/expect_output.txt +++ b/test/moduletest/datetimezone/expect_output.txt @@ -12,3 +12,4 @@ # limitations under the License. true +RangeError: invalid timeZone diff --git a/test/moduletest/proxyrelease/BUILD.gn b/test/moduletest/proxyrelease/BUILD.gn index 3b0f1d906a..c7c0016caf 100644 --- a/test/moduletest/proxyrelease/BUILD.gn +++ b/test/moduletest/proxyrelease/BUILD.gn @@ -13,6 +13,6 @@ import("//arkcompiler/ets_runtime/test/test_helper.gni") -host_moduletest_assert_action("proxyrelease") { +host_moduletest_action("proxyrelease") { deps = [] } -- Gitee From 52dea3300a54884e42765122ec7661cbe2eef793 Mon Sep 17 00:00:00 2001 From: wuxiesaber Date: Fri, 24 Jan 2025 10:44:32 +0800 Subject: [PATCH 5/5] fix no exception return Issue: https://gitee.com/openharmony/arkcompiler_ets_runtime/issues/IBJL5S Signed-off-by: wuxiesaber Change-Id: Ic44740edf322dccf049e0c65d59cc69f1c386653 --- ecmascript/js_for_in_iterator.cpp | 1 + test/moduletest/BUILD.gn | 3 ++ test/moduletest/nextinternalslowpath/BUILD.gn | 18 ++++++++ .../nextinternalslowpath/expect_output.txt | 14 +++++++ .../nextinternalslowpath.js | 41 +++++++++++++++++++ 5 files changed, 77 insertions(+) create mode 100644 test/moduletest/nextinternalslowpath/BUILD.gn create mode 100644 test/moduletest/nextinternalslowpath/expect_output.txt create mode 100644 test/moduletest/nextinternalslowpath/nextinternalslowpath.js diff --git a/ecmascript/js_for_in_iterator.cpp b/ecmascript/js_for_in_iterator.cpp index 8cc70aa4b5..6d8a1bc44b 100644 --- a/ecmascript/js_for_in_iterator.cpp +++ b/ecmascript/js_for_in_iterator.cpp @@ -120,6 +120,7 @@ JSTaggedValue JSForInIterator::NextInternalSlowpath(JSThread *thread, const JSHa break; } has = HasProperty(thread, receiverHandle, keyHandle); + RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread); if (has) { break; } diff --git a/test/moduletest/BUILD.gn b/test/moduletest/BUILD.gn index f28d42394c..1c2dffc6f1 100644 --- a/test/moduletest/BUILD.gn +++ b/test/moduletest/BUILD.gn @@ -111,6 +111,7 @@ group("ark_js_moduletest") { "multiprotoic", "negintmin", "newobjdynrange", + "nextinternalslowpath", "objectcloneproperties", "objectdefineproperties", "objectgetownproperty", @@ -289,6 +290,7 @@ group("ark_asm_test") { "multiprotoic", "negintmin", "newobjdynrange", + "nextinternalslowpath", "number", "objectcloneproperties", "objecthasownproperty", @@ -430,6 +432,7 @@ group("ark_asm_single_step_test") { "multiprotoic", "negintmin", "newobjdynrange", + "nextinternalslowpath", "objectcloneproperties", "objecthasownproperty", "objectkeys", diff --git a/test/moduletest/nextinternalslowpath/BUILD.gn b/test/moduletest/nextinternalslowpath/BUILD.gn new file mode 100644 index 0000000000..a3b9aeceef --- /dev/null +++ b/test/moduletest/nextinternalslowpath/BUILD.gn @@ -0,0 +1,18 @@ +# Copyright (c) 2025 Huawei Device Co., Ltd. +# 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. + +import("//arkcompiler/ets_runtime/test/test_helper.gni") + +host_moduletest_action("nextinternalslowpath") { + deps = [] +} diff --git a/test/moduletest/nextinternalslowpath/expect_output.txt b/test/moduletest/nextinternalslowpath/expect_output.txt new file mode 100644 index 0000000000..52a34023e7 --- /dev/null +++ b/test/moduletest/nextinternalslowpath/expect_output.txt @@ -0,0 +1,14 @@ +# Copyright (c) 2025 Huawei Device Co., Ltd. +# 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. + +TypeError: Cannot define property diff --git a/test/moduletest/nextinternalslowpath/nextinternalslowpath.js b/test/moduletest/nextinternalslowpath/nextinternalslowpath.js new file mode 100644 index 0000000000..d77958c34b --- /dev/null +++ b/test/moduletest/nextinternalslowpath/nextinternalslowpath.js @@ -0,0 +1,41 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * 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. + */ + +/* + * @tc.name:nextinternalslowpath + * @tc.desc:test JSForInIterator::NextInternalSlowpath + * @tc.type: FUNC + * @tc.require: issueIBJL5S + */ + +// This case aims to test if JSForInIterator::NextInternalSlowpath could return exception. +{ + function test_func() {} + function f0() {} + let v12 = new Proxy(Object.create(null, {x: {enumerable: true}}), { + getOwnPropertyDescriptor(v13, v14) { + if (v13 != null && typeof v13 == "object") { + Object.defineProperty(v13, test_func(), {get: function () {}}); + } + return Reflect.getOwnPropertyDescriptor(v13, v14); + } + }); + try { + for (let v15 in v12) {} + f0([1]); + } catch (e) { + print(e); + } +} -- Gitee