On Sat, Feb 28, 2015 at 04:27:21PM -0500, Mike Frysinger wrote:
> i guess we just ignore the failure on s390/s390x and let upstream sort it out.

I was going to apply the following patch but, surprisingly,
it fails on ppc64:

[00001fffffeb61c4] mmap(NULL, 65536, PROT_NONE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 
0) = 0x1ffffff80000
...
[pid 12345] [0000000010000760] --- SIGSEGV {si_signo=SIGSEGV, 
si_code=SEGV_ACCERR, si_addr=0x1ffffff80000} ---

--- a/tests/pc.c
+++ b/tests/pc.c
@@ -1,23 +1,18 @@
-#ifdef HAVE_CONFIG_H
-# include "config.h"
-#endif
-#include <dlfcn.h>
-#include <fcntl.h>
 #include <unistd.h>
 #include <sys/mman.h>
 #include <sys/wait.h>
-#include <sys/sendfile.h>
 
 int main(void)
 {
-       const unsigned long pagesize = sysconf(_SC_PAGESIZE);
+       const unsigned long size = sysconf(_SC_PAGESIZE);
+       void *addr;
 
-       /* write instruction pointer length to the log */
-       if (write(-1, NULL, 2 * sizeof(void *)) >= 0)
+       addr = mmap(NULL, size, PROT_NONE, MAP_PRIVATE | MAP_ANONYMOUS, -1, 0);
+       if (!addr || addr == MAP_FAILED)
                return 77;
 
-       /* just a noticeable line in the log */
-       if (munmap(&main, 0) >= 0)
+       /* write instruction pointer length to the log */
+       if (write(-1, NULL, 2 * sizeof(void *)) >= 0)
                return 77;
 
        int pid = fork();
@@ -25,29 +20,13 @@ int main(void)
                return 77;
 
        if (!pid) {
-               const unsigned long mask = ~(pagesize - 1);
-               unsigned long addr = (unsigned long) &main & mask;
-               unsigned long size = pagesize << 1;
+               union {
+                       void (*f)(void);
+                       void *p;
+               } crash = { .p = addr };
 
-#ifdef HAVE_DLADDR
-               Dl_info info;
-               if (dladdr(&main, &info)) {
-                       const unsigned long base =
-                               (unsigned long) info.dli_fbase & mask;
-                       if (base < addr) {
-                               size += addr - base;
-                               addr = base;
-                       }
-               } else
-#endif
-               {
-                       addr -= size;
-                       size <<= 1;
-               }
+               crash.f();
 
-               /* SIGSEGV is expected */
-               (void) munmap((void *) addr, size);
-               (void) munmap((void *) addr, size);
                return 77;
        }
 
@@ -57,10 +36,5 @@ int main(void)
            WTERMSIG(status) != SIGSEGV)
                return 77;
 
-       /* dump process map for debug purposes */
-       close(0);
-       if (!open("/proc/self/maps", O_RDONLY))
-               (void) sendfile(1, 0, NULL, pagesize);
-
        return 0;
 }
--- a/tests/pc.test
+++ b/tests/pc.test
@@ -17,13 +17,13 @@ $STRACE $args > "$OUT" 2> "$LOG" || {
        fail_ "$STRACE $args does not work"
 }
 
-len="$(sed -n 's/^\[[[:xdigit:]]\+\] write(-1, NULL, 
\([[:digit:]]\{1,2\}\))[[:space:]]\+= -1 .*/\1/p' "$LOG")" &&
+len="$(sed -n 's/^\[[[:xdigit:]]\+\] write(-1, NULL, \([[:digit:]]\{1,2\}\)) 
\+= -1 .*/\1/p' "$LOG")" &&
 [ -n "$len" ] &&
 pid="$(sed -n 's/^\[[[:xdigit:]]\{'"$len"'\}\] --- SIGCHLD {si_signo=SIGCHLD, 
si_code=CLD_\(KILLED\|DUMPED\), si_pid=\([[:digit:]]\+\), .*/\2/p' "$LOG")" &&
 [ -n "$pid" ] &&
-ip="$(sed -n 's/^\[pid \+'"$pid"'\] \[\([[:xdigit:]]\{'"$len"'\}\)] --- 
SIGSEGV {.*} ---$/\1/p' "$LOG")" &&
-[ -n "$ip" ] &&
-addr="$(echo "$ip" |sed 's/^0\+//')" &&
+addr="$(sed -n 's/^\[pid \+'"$pid"'\] \[\([[:xdigit:]]\{'"$len"'\}\)] --- 
SIGSEGV {si_signo=SIGSEGV, si_code=SEGV_[^,]\+, si_addr=0x[[:xdigit:]]\+} 
---$/\1/p' "$LOG")" &&
+[ -n "$addr" ] &&
+addr="$(echo "$addr" |sed 's/^0\+//')" &&
 [ -n "$addr" ] || {
        cat "$OUT" "$LOG"
        fail_ "$STRACE $args output mismatch"
@@ -37,8 +37,7 @@ grep_log()
        }
 }
 
-grep_log '\[[[:xdigit:]]\{'"$len"'\}\] munmap(0x[[:xdigit:]]\+, 
0)[[:space:]]\+= -1 .*'
-grep_log '\[pid \+'"$pid"'\] \['"$ip"'\] --- SIGSEGV {si_signo=SIGSEGV, 
si_code=SEGV_MAPERR, si_addr=0x'"$addr"'} ---'
+grep_log '\[[[:xdigit:]]\+\] [^(]*mmap[^(]*(NULL, [[:digit:]]\+, PROT_NONE, 
MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) \+= 0x'"$addr"
 grep_log '\[pid \+'"$pid"'\] \[?\{'"$len"'\}\] +++ killed by SIGSEGV\( (core 
dumped)\)\? +++'
 grep_log '\[?\{'"$len"'\}\] +++ exited with 0 +++'
 

-- 
ldv

Attachment: pgpLbbC8uhOJE.pgp
Description: PGP signature

------------------------------------------------------------------------------
Dive into the World of Parallel Programming The Go Parallel Website, sponsored
by Intel and developed in partnership with Slashdot Media, is your hub for all
things parallel software development, from weekly thought leadership blogs to
news, videos, case studies, tutorials and more. Take a look and join the 
conversation now. http://goparallel.sourceforge.net/
_______________________________________________
Strace-devel mailing list
Strace-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/strace-devel

Reply via email to