mirror of
https://gitee.com/openharmony/arkcompiler_ets_runtime
synced 2024-10-07 08:03:29 +00:00
Desciption: Deal with the "use after free" error
occurs while debugging ark_js_vm executable on windows. Details: Enclose the part where the LocalScope object should take effect with a pair of braces. Thus, the destructor of the LocalScope object will be called at the right brace which is above the JSNApi::DestroyJSVM() function. Issue: https://gitee.com/openharmony/ark_js_runtime/issues/I5C7XG Signed-off-by: Gongyuhang <gongyuhang5@huawei.com>
This commit is contained in:
parent
43e0608f7d
commit
496687fe52
@ -110,29 +110,32 @@ int Main(const int argc, const char **argv)
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
LocalScope scope(vm);
|
{
|
||||||
std::string entry = entrypoint.GetValue();
|
LocalScope scope(vm);
|
||||||
arg_list_t pandaFileNames = files.GetValue();
|
std::string entry = entrypoint.GetValue();
|
||||||
std::string triple = runtimeOptions.GetTargetTriple();
|
arg_list_t pandaFileNames = files.GetValue();
|
||||||
std::string outputFileName = runtimeOptions.GetAOTOutputFile();
|
std::string triple = runtimeOptions.GetTargetTriple();
|
||||||
size_t optLevel = runtimeOptions.GetOptLevel();
|
std::string outputFileName = runtimeOptions.GetAOTOutputFile();
|
||||||
BytecodeStubCSigns::Initialize();
|
size_t optLevel = runtimeOptions.GetOptLevel();
|
||||||
CommonStubCSigns::Initialize();
|
BytecodeStubCSigns::Initialize();
|
||||||
RuntimeStubCSigns::Initialize();
|
CommonStubCSigns::Initialize();
|
||||||
|
RuntimeStubCSigns::Initialize();
|
||||||
|
|
||||||
std::string logMethods = vm->GetJSOptions().GetlogCompiledMethods();
|
std::string logMethods = vm->GetJSOptions().GetlogCompiledMethods();
|
||||||
AotLog log(logMethods);
|
AotLog log(logMethods);
|
||||||
AOTFileGenerator generator(&log, vm);
|
AOTFileGenerator generator(&log, vm);
|
||||||
PassManager passManager(vm, entry, triple, optLevel, &log);
|
PassManager passManager(vm, entry, triple, optLevel, &log);
|
||||||
for (const auto &fileName : pandaFileNames) {
|
for (const auto &fileName : pandaFileNames) {
|
||||||
COMPILER_LOG(INFO) << "AOT start to execute ark file: " << fileName;
|
COMPILER_LOG(INFO) << "AOT start to execute ark file: " << fileName;
|
||||||
if (passManager.Compile(fileName, generator) == false) {
|
if (passManager.Compile(fileName, generator) == false) {
|
||||||
ret = false;
|
ret = false;
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
generator.SaveAOTFile(outputFileName);
|
||||||
|
generator.GenerateSnapshotFile();
|
||||||
}
|
}
|
||||||
generator.SaveAOTFile(outputFileName);
|
|
||||||
generator.GenerateSnapshotFile();
|
|
||||||
JSNApi::DestroyJSVM(vm);
|
JSNApi::DestroyJSVM(vm);
|
||||||
paParser.DisableTail();
|
paParser.DisableTail();
|
||||||
return ret ? 0 : -1;
|
return ret ? 0 : -1;
|
||||||
|
@ -109,16 +109,18 @@ int Main(const int argc, const char **argv)
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
LocalScope scope(vm);
|
{
|
||||||
std::string entry = entrypoint.GetValue();
|
LocalScope scope(vm);
|
||||||
|
std::string entry = entrypoint.GetValue();
|
||||||
|
|
||||||
arg_list_t fileNames = files.GetValue();
|
arg_list_t fileNames = files.GetValue();
|
||||||
for (const auto &fileName : fileNames) {
|
for (const auto &fileName : fileNames) {
|
||||||
auto res = JSNApi::Execute(vm, fileName, entry);
|
auto res = JSNApi::Execute(vm, fileName, entry);
|
||||||
if (!res) {
|
if (!res) {
|
||||||
std::cerr << "Cannot execute panda file '" << fileName << "' with entry '" << entry << "'" << std::endl;
|
std::cerr << "Cannot execute panda file '" << fileName << "' with entry '" << entry << "'" << std::endl;
|
||||||
ret = false;
|
ret = false;
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user