From c17c4b85ca9e9af75bc16c9e49b6bf0b3ee6b4c8 Mon Sep 17 00:00:00 2001 From: Mike Frysinger Date: Sun, 20 Sep 2015 03:40:16 -0400 Subject: libsandbox: work around process_vm_readv EFAULTs Some people are seeing this call fail, but it's not clear why. Include more debugging output so as to improve the reports, and let the code fall back to the existing ptrace logic since that seems to work. This will at least unblock people's builds. URL: https://bugs.gentoo.org/560396 Reported-by: Jeroen Roovers Signed-off-by: Mike Frysinger --- libsandbox/trace.c | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/libsandbox/trace.c b/libsandbox/trace.c index 1d40392..ed05c4d 100644 --- a/libsandbox/trace.c +++ b/libsandbox/trace.c @@ -104,10 +104,23 @@ static char *do_peekstr(unsigned long lptr) while (1) { if (process_vm_readv(trace_pid, &liov, 1, &riov, 1, 0) == -1) { - if (errno == ENOSYS) + int e = errno; + if (e == ENOSYS) break; + sb_eqawarn("process_vm_readv(%i, %p{%p, %zu}, 1, %p{%p, %zu}, 1, 0) failed: %s\n", + trace_pid, + &liov, liov.iov_base, liov.iov_len, + &riov, riov.iov_base, riov.iov_len, + strerror(e)); + if (e == EFAULT) { + /* This sometimes happens, but it's not clear why. + * Throw some extended debugging info before falling + * back to the ptrace code. #560396 + */ + break; + } sb_ebort("ISE:do_peekstr: process_vm_readv() hates us: %s\n", - strerror(errno)); + strerror(e)); } for (i = 0; i < liov.iov_len; ++i) -- cgit v1.2.3-18-g5258