From 57d39fd6bcf25225596f7e788195d44e6ea65445 Mon Sep 17 00:00:00 2001 From: milkpotatoes Date: Sat, 23 Aug 2025 10:54:47 +0800 Subject: [PATCH] Fix crash of JsPandaFileTest on arm arch Issue: https://gitee.com/openharmony/arkcompiler_ets_runtime/issues/ICUJAY Signed-off-by: milkpotatoes Change-Id: I7ab1a9ec502fb507e68e09800548dcb6c0b01cac --- .../jspandafile/tests/js_pandafile_executor_test.cpp | 8 ++++++-- .../jspandafile/tests/js_pandafile_manager_test.cpp | 6 ++++-- .../jspandafile/tests/panda_file_translator_test.cpp | 3 --- 3 files changed, 10 insertions(+), 7 deletions(-) diff --git a/ecmascript/jspandafile/tests/js_pandafile_executor_test.cpp b/ecmascript/jspandafile/tests/js_pandafile_executor_test.cpp index ccfce05e7b..05e656179a 100644 --- a/ecmascript/jspandafile/tests/js_pandafile_executor_test.cpp +++ b/ecmascript/jspandafile/tests/js_pandafile_executor_test.cpp @@ -87,8 +87,6 @@ HWTEST_F_L0(JSPandaFileExecutorTest, Execute) Expected result = JSPandaFileExecutor::Execute(thread, pf.get(), JSPandaFile::ENTRY_MAIN_FUNCTION); EXPECT_TRUE(result); - - pfManager->RemoveJSPandaFile(pf.get()); } HWTEST_F_L0(JSPandaFileExecutorTest, ExecuteFromFile) @@ -126,6 +124,9 @@ HWTEST_F_L0(JSPandaFileExecutorTest, ExecuteFromFile) pfManager->RemoveJSPandaFile(pf.get()); std::shared_ptr foundPf = pfManager->FindJSPandaFile(fileName); EXPECT_TRUE(foundPf == nullptr); + + // readd panda file into mgr, due to panda file should managed by gc. + pfManager->AddJSPandaFile(pf); } HWTEST_F_L0(JSPandaFileExecutorTest, ExecuteFromBuffer) @@ -163,6 +164,9 @@ HWTEST_F_L0(JSPandaFileExecutorTest, ExecuteFromBuffer) pfManager->RemoveJSPandaFile(pf.get()); std::shared_ptr foundPf = pfManager->FindJSPandaFile(fileName); EXPECT_TRUE(foundPf == nullptr); + + // readd panda file into mgr, due to panda file should managed by gc. + pfManager->AddJSPandaFile(pf); } HWTEST_F_L0(JSPandaFileExecutorTest, ExecuteAbcFileWithSingletonPatternFlag) diff --git a/ecmascript/jspandafile/tests/js_pandafile_manager_test.cpp b/ecmascript/jspandafile/tests/js_pandafile_manager_test.cpp index 0f2e3ea25f..fe398fb60a 100644 --- a/ecmascript/jspandafile/tests/js_pandafile_manager_test.cpp +++ b/ecmascript/jspandafile/tests/js_pandafile_manager_test.cpp @@ -192,6 +192,10 @@ HWTEST_F_L0(JSPandaFileManagerTest, MultiEcmaVM_Add_Find_Remove_JSPandaFile) std::shared_ptr afterRemovePf2 = pfManager->FindJSPandaFile(filename2); EXPECT_EQ(afterRemovePf1, nullptr); EXPECT_EQ(afterRemovePf2, nullptr); + + // panda file would be managed by gc, readd to panda file manager after check + pfManager->AddJSPandaFile(pf1); + pfManager->AddJSPandaFile(pf2); } void CreateJSPandaFileAndConstpool(EcmaVM *vm) @@ -298,8 +302,6 @@ HWTEST_F_L0(JSPandaFileManagerTest, GenerateProgram) JSHandle mainFunc(thread, program->GetMainFunction(thread)); JSHandle funcName = JSFunction::GetFunctionName(thread, JSHandle(mainFunc)); EXPECT_STREQ(EcmaStringAccessor(JSHandle::Cast(funcName)).ToCString(thread).c_str(), "foo"); - - pfManager->RemoveJSPandaFile(pf.get()); } HWTEST_F_L0(JSPandaFileManagerTest, GetJSPtExtractor) diff --git a/ecmascript/jspandafile/tests/panda_file_translator_test.cpp b/ecmascript/jspandafile/tests/panda_file_translator_test.cpp index d8edae1b32..e92178a79d 100644 --- a/ecmascript/jspandafile/tests/panda_file_translator_test.cpp +++ b/ecmascript/jspandafile/tests/panda_file_translator_test.cpp @@ -96,8 +96,6 @@ HWTEST_F_L0(PandaFileTranslatorTest, GenerateProgram) JSHandle mainFunc2(thread, program2->GetMainFunction(thread)); JSHandle funcName2 = JSFunction::GetFunctionName(thread, JSHandle(mainFunc2)); EXPECT_STREQ(EcmaStringAccessor(JSHandle::Cast(funcName2)).ToCString(thread).c_str(), "func_main_0"); - - pfManager->RemoveJSPandaFile(pf.get()); } HWTEST_F_L0(PandaFileTranslatorTest, TranslateClasses) @@ -131,6 +129,5 @@ HWTEST_F_L0(PandaFileTranslatorTest, TranslateClasses) EXPECT_TRUE(pf->FindMethodLiteral(methodId[0].GetOffset()) != nullptr); EXPECT_EQ(pf->FindMethodLiteral(methodId[0].GetOffset())->GetFunctionKind(), ecmascript::FunctionKind::NONE_FUNCTION); - pfManager->RemoveJSPandaFile(pf.get()); } } // namespace panda::test -- Gitee