commit:     c17c4b85ca9e9af75bc16c9e49b6bf0b3ee6b4c8
Author:     Mike Frysinger <vapier <AT> gentoo <DOT> org>
AuthorDate: Sun Sep 20 07:40:16 2015 +0000
Commit:     Mike Frysinger <vapier <AT> gentoo <DOT> org>
CommitDate: Sun Sep 20 07:40:16 2015 +0000
URL:        https://gitweb.gentoo.org/proj/sandbox.git/commit/?id=c17c4b85

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 <jer <AT> gentoo.org>
Signed-off-by: Mike Frysinger <vapier <AT> gentoo.org>

 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)

Reply via email to