diff --git a/interfaces/innerkits/unwinder/src/elf/elf_factory.cpp b/interfaces/innerkits/unwinder/src/elf/elf_factory.cpp index cbe6706288992a4ad849fd8cae7f04dbaa6c9513..f6c2172957244f3e1c6ca80edcdf5f149fa534c6 100644 --- a/interfaces/innerkits/unwinder/src/elf/elf_factory.cpp +++ b/interfaces/innerkits/unwinder/src/elf/elf_factory.cpp @@ -205,12 +205,12 @@ std::shared_ptr CompressHapElfFactory::Create() DFXLOGE("current hap map item or prev map item , maybe pc is wrong?"); return nullptr; } - std::string realPath = filePath_; - if (!RealPath(filePath_, realPath) || !EndsWith(realPath, ".hap") || !StartsWith(realPath, "/proc")) { - DFXLOGE("Illegal file path, please check file: %{public}s", realPath.c_str()); + // Do not use the realpath function, as it will fail when filePath_ is a sandbox path. + if (!StartsWith(filePath_, "/proc") || !EndsWith(filePath_, ".hap")) { + DFXLOGD("Illegal file path, please check file: %{public}s", filePath_.c_str()); return nullptr; } - int fd = OHOS_TEMP_FAILURE_RETRY(open(realPath.c_str(), O_RDONLY)); + int fd = OHOS_TEMP_FAILURE_RETRY(open(filePath_.c_str(), O_RDONLY)); if (fd < 0) { DFXLOGE("Failed to open hap file, errno(%{public}d)", errno); return nullptr;