From 8d4f2a4ebe37b62b1188188d66e57f5eba06a7ff Mon Sep 17 00:00:00 2001 From: zhou_xq Date: Tue, 24 Jun 2025 11:32:46 +0800 Subject: [PATCH] fix the alarm Signed-off-by: zhou_xq --- .../unwinder/src/memory/dfx_accessors.cpp | 18 ++++++++++++------ .../unwinder/src/utils/safe_reader.cpp | 2 +- 2 files changed, 13 insertions(+), 7 deletions(-) diff --git a/interfaces/innerkits/unwinder/src/memory/dfx_accessors.cpp b/interfaces/innerkits/unwinder/src/memory/dfx_accessors.cpp index 95aa9968a..df4be0119 100644 --- a/interfaces/innerkits/unwinder/src/memory/dfx_accessors.cpp +++ b/interfaces/innerkits/unwinder/src/memory/dfx_accessors.cpp @@ -100,13 +100,19 @@ NO_SANITIZE int DfxAccessorsLocal::AccessMem(uintptr_t addr, uintptr_t *val, voi *val = *reinterpret_cast(addr); return UNW_ERROR_NONE; } - if (CreatePipe() && - OHOS_TEMP_FAILURE_RETRY(syscall(SYS_write, pfd_[PIPE_WRITE], addr, sizeof(uintptr_t))) != -1 && - OHOS_TEMP_FAILURE_RETRY(syscall(SYS_read, pfd_[PIPE_READ], val, sizeof(uintptr_t))) != -1) { - return UNW_ERROR_NONE; + if (!CreatePipe()) { + DFXLOGU("Failed to access addr, the pipe create fail, errno:%{public}d", errno); + return UNW_ERROR_INVALID_MEMORY; + } + if (OHOS_TEMP_FAILURE_RETRY(syscall(SYS_write, pfd_[PIPE_WRITE], addr, sizeof(uintptr_t))) == -1) { + DFXLOGU("Failed to access addr, the pipe write fail, errno:%{public}d", errno); + return UNW_ERROR_INVALID_MEMORY; } - DFXLOGU("Failed to access addr"); - return UNW_ERROR_INVALID_MEMORY; + if (OHOS_TEMP_FAILURE_RETRY(syscall(SYS_read, pfd_[PIPE_READ], val, sizeof(uintptr_t))) == -1) { + DFXLOGU("Failed to access addr, the pipe read fail, errno:%{public}d", errno); + return UNW_ERROR_INVALID_MEMORY; + } + return UNW_ERROR_NONE; } int DfxAccessorsLocal::AccessReg(int reg, uintptr_t *val, void *arg) diff --git a/interfaces/innerkits/unwinder/src/utils/safe_reader.cpp b/interfaces/innerkits/unwinder/src/utils/safe_reader.cpp index 25e289eb0..748ba2b13 100644 --- a/interfaces/innerkits/unwinder/src/utils/safe_reader.cpp +++ b/interfaces/innerkits/unwinder/src/utils/safe_reader.cpp @@ -78,6 +78,6 @@ NO_SANITIZE size_t SafeReader::CopyReadbaleBufSafe(uintptr_t destPtr, size_t des uintptr_t SafeReader::GetCurrentPageEndAddr(uintptr_t addr) { - int pageSize = getpagesize(); + uintptr_t pageSize = static_cast(getpagesize()); return (addr + pageSize) & (~(pageSize - 1)); } -- Gitee