Skip to content

Commit 70ce62e

Browse files
fixup! fixup! [libunwind] Replace process_vm_readv with pipe
1 parent 770c0d3 commit 70ce62e

File tree

1 file changed

+9
-9
lines changed

1 file changed

+9
-9
lines changed

libunwind/src/UnwindCursor.hpp

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2969,31 +2969,31 @@ bool UnwindCursor<A, R>::getFunctionName(char *buf, size_t bufLen,
29692969
#if defined(_LIBUNWIND_CHECK_LINUX_SIGRETURN)
29702970
template <typename A, typename R>
29712971
bool UnwindCursor<A, R>::isReadableAddr(const pint_t addr) const {
2972-
// This code is heavily based on Abseil's 'address_is_readable.cc',
2973-
// which is Copyright Abseil Authors (2017).
2972+
// We use SYS_rt_sigprocmask, inspired by Abseil's AddressIsReadable.
29742973

29752974
const auto sigsetAddr = reinterpret_cast<sigset_t *>(addr);
29762975
// We have to check that addr is nullptr because sigprocmask allows that
29772976
// as an argument without failure.
29782977
if (!sigsetAddr)
29792978
return false;
2979+
const auto saveErrno = errno;
29802980
// We MUST use a raw syscall here, as wrappers may try to access
29812981
// sigsetAddr which may cause a SIGSEGV. A raw syscall however is
29822982
// safe. Additionally, we need to pass the kernel_sigset_size, which is
29832983
// different from libc sizeof(sigset_t). For the majority of architectures,
29842984
// it's 64 bits (_NSIG), and libc NSIG is _NSIG + 1.
29852985
const auto kernelSigsetSize = NSIG / 8;
2986-
const int Result = syscall(SYS_rt_sigprocmask, /*how=*/~0, sigsetAddr,
2987-
nullptr, kernelSigsetSize);
2988-
(void)Result;
2986+
[[maybe_unused]] const int Result = syscall(
2987+
SYS_rt_sigprocmask, /*how=*/~0, sigsetAddr, nullptr, kernelSigsetSize);
29892988
// Because our "how" is invalid, this syscall should always fail, and our
2990-
// errno should always be EINVAL or an EFAULT. EFAULT is not guaranteed
2991-
// by the POSIX standard. Additionally, this relies on the Linux kernel
2992-
// to check copy_from_user before checking if the "how" argument is
2989+
// errno should always be EINVAL or an EFAULT. This relies on the Linux
2990+
// kernel to check copy_from_user before checking if the "how" argument is
29932991
// invalid.
29942992
assert(Result == -1);
29952993
assert(errno == EFAULT || errno == EINVAL);
2996-
return errno != EFAULT;
2994+
const auto readable = errno != EFAULT;
2995+
errno = saveErrno;
2996+
return readable;
29972997
}
29982998
#endif
29992999

0 commit comments

Comments
 (0)