Skip to content

Commit 2346a2a

Browse files
fixup! fixup! [libunwind] Replace process_vm_readv with pipe
1 parent aa402a4 commit 2346a2a

File tree

1 file changed

+12
-12
lines changed

1 file changed

+12
-12
lines changed

libunwind/src/UnwindCursor.hpp

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2970,8 +2970,7 @@ bool UnwindCursor<A, R>::getFunctionName(char *buf, size_t bufLen,
29702970
template <typename A, typename R>
29712971
bool UnwindCursor<A, R>::isReadableAddr(const pint_t addr) const {
29722972
// This code is heavily based on Abseil's 'address_is_readable.cc',
2973-
// which is Copyright Abseil Authors (2017), and provided under
2974-
// the Apache License 2.0.
2973+
// which is Copyright Abseil Authors (2017).
29752974

29762975
// Align to 8-bytes.
29772976
const auto alignedAddr = addr & ~pint_t{7};
@@ -2980,19 +2979,20 @@ bool UnwindCursor<A, R>::isReadableAddr(const pint_t addr) const {
29802979
// as an argument without failure.
29812980
if (!sigsetAddr)
29822981
return false;
2983-
2984-
// We MUST use the raw sigprocmask syscall here, as wrappers may try to
2985-
// access sigsetAddr which may cause a SIGSEGV. The raw syscall however is
2982+
// We MUST use a raw syscall here, as wrappers may try to access
2983+
// sigsetAddr which may cause a SIGSEGV. A raw syscall however is
29862984
// safe. Additionally, we need to pass the kernel_sigset_size, which is
2987-
// different from libc sizeof(sigset_t). Some archs have sigset_t
2988-
// defined as unsigned long, so let's use that.
2989-
const auto approxKernelSigsetSize = sizeof(unsigned long);
2990-
[[maybe_unused]] const int Result =
2991-
syscall(SYS_rt_sigprocmask, /*how=*/~0, sigsetAddr, sigsetAddr,
2992-
approxKernelSigsetSize);
2985+
// different from libc sizeof(sigset_t). 8 seems to work for both 64bit and
2986+
// 32bit archs.
2987+
const auto approxKernelSigsetSize = 8;
2988+
int Result = syscall(SYS_rt_sigprocmask, /*how=*/~0, sigsetAddr, nullptr,
2989+
approxKernelSigsetSize);
2990+
(void)Result;
29932991
// Because our "how" is invalid, this syscall should always fail, and our
29942992
// errno should always be EINVAL or an EFAULT. EFAULT is not guaranteed
2995-
// by the POSIX standard, so this is (for now) Linux specific.
2993+
// by the POSIX standard. Additionally, this relies on the Linux kernel
2994+
// to check copy_from_user before checking if the "how" argument is
2995+
// invalid.
29962996
assert(Result == -1);
29972997
assert(errno == EFAULT || errno == EINVAL);
29982998
return errno != EFAULT;

0 commit comments

Comments
 (0)