Index: user/pho/stress2/misc/fifo3.sh =================================================================== --- user/pho/stress2/misc/fifo3.sh (revision 317556) +++ user/pho/stress2/misc/fifo3.sh (revision 317557) @@ -1,211 +1,211 @@ #!/bin/sh # # Copyright (c) 2014 EMC Corp. # All rights reserved. # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions # are met: # 1. Redistributions of source code must retain the above copyright # notice, this list of conditions and the following disclaimer. # 2. Redistributions in binary form must reproduce the above copyright # notice, this list of conditions and the following disclaimer in the # documentation and/or other materials provided with the distribution. # # THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND # ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE # ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE # FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL # DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS # OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) # HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT # LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY # OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF # SUCH DAMAGE. # # $FreeBSD$ # # Demonstrate that fts_read(3) will open a fifo for read. # Not seen on a pristine FreeBSD. # $ while ./fifo.sh; do date; done # Wed Oct 1 14:07:41 CEST 2014 # Wed Oct 1 14:09:58 CEST 2014 # FAIL # $ ps -l19547 # UID PID PPID CPU PRI NI VSZ RSS MWCHAN STAT TT TIME COMMAND # 0 19547 19544 0 25 0 12176 3996 fifoor I 0 0:08.19 /tmp/fifo # $ gdb /tmp/fifo 19547 # GNU gdb 6.1.1 [FreeBSD] # Copyright 2004 Free Software Foundation, Inc. # GDB is free software, covered by the GNU General Public License, and you are # welcome to change it and/or distribute copies of it under certain conditions. # Type "show copying" to see the conditions. # There is absolutely no warranty for GDB. Type "show warranty" for details. # This GDB was configured as "amd64-marcel-freebsd"... # Attaching to program: /tmp/fifo, process 19547 # Reading symbols from /lib/libc.so.7...done. # Loaded symbols for /lib/libc.so.7 # Reading symbols from /libexec/ld-elf.so.1...done. # Loaded symbols for /libexec/ld-elf.so.1 # 0x00000008008a9ab8 in enc_openat () from /lib/libc.so.7 # (gdb) bt # #0 0x00000008008a9ab8 in enc_openat () from /lib/libc.so.7 # #1 0x00000008008a581b in fts_read () from /lib/libc.so.7 # #2 0x00000008008a4f24 in fts_read () from /lib/libc.so.7 # #3 0x0000000000400ee9 in test () at /tmp/fifo.c:86 # #4 0x0000000000400fd8 in main () at /tmp/fifo.c:108 # (gdb) f 3 # #3 0x0000000000400ee9 in test () at /tmp/fifo.c:86 # 86 while ((p = fts_read(fts)) != NULL) { # Current language: auto; currently minimal # (gdb) # . ../default.cfg cat > /tmp/fifo3.c < #include #include #include #include #include #include #include #include #include #define LOOPS 50 #define PARALLEL 4 void tmkfifo(void) { pid_t pid; int i, j; char name[80]; setproctitle(__func__); pid = getpid(); for (j = 0; j < LOOPS; j++) { for (i = 0; i < 1000; i++) { snprintf(name, sizeof(name), "fifo.%d.%06d", pid, i); if (mkfifo(name, 0644) == -1) err(1, "mkfifo(%s)", name); } for (i = 0; i < 1000; i++) { snprintf(name, sizeof(name), "fifo.%d.%06d", pid, i); if (unlink(name) == -1) err(1, "unlink(%s)", name); } } _exit(0); } void tmkdir(void) { pid_t pid; int i, j; char name[80]; setproctitle(__func__); pid = getpid(); for (j = 0; j < LOOPS; j++) { for (i = 0; i < 1000; i++) { snprintf(name, sizeof(name), "dir.%d.%06d", pid, i); if (mkdir(name, 0644) == -1) err(1, "mkfifo(%s)", name); } for (i = 0; i < 1000; i++) { snprintf(name, sizeof(name), "dir.%d.%06d", pid, i); if (rmdir(name) == -1) err(1, "unlink(%s)", name); } } _exit(0); } void test(void) { FTS *fts; FTSENT *p; int ftsoptions, i; char *args[2]; if (fork() == 0) tmkfifo(); if (fork() == 0) tmkdir(); ftsoptions = FTS_PHYSICAL; args[0] = "."; args[1] = 0; for (i = 0; i < LOOPS; i++) { if ((fts = fts_open(args, ftsoptions, NULL)) == NULL) err(1, "fts_open"); while ((p = fts_read(fts)) != NULL) { #if defined(TEST) fprintf(stdout, "%s\n", p->fts_path); #endif } if (errno != 0 && errno != ENOENT) err(1, "fts_read"); if (fts_close(fts) == -1) err(1, "fts_close()"); } wait(NULL); wait(NULL); _exit(0); } int main(void) { int i; for (i = 0; i < PARALLEL; i++) if (fork() == 0) test(); for (i = 0; i < PARALLEL; i++) wait(NULL); return (0); } EOF mycc -o /tmp/fifo3 -Wall -Wextra -O0 -g /tmp/fifo3.c || exit 1 mount | grep $mntpoint | grep -q /dev/md && umount -f $mntpoint [ -c /dev/md$mdstart ] && mdconfig -d -u $mdstart mdconfig -a -t swap -s 1g -u $mdstart || exit 1 bsdlabel -w md$mdstart auto newfs md${mdstart}$part > /dev/null mount /dev/md${mdstart}$part $mntpoint (cd $mntpoint; /tmp/fifo3 ) & while pgrep -q fifo3; do - ps -l | grep -v grep | grep -q fifoor && + ps -lx | grep -v grep | grep -q fifoor && { echo FAIL; exit 1; } sleep 2 done wait while mount | grep $mntpoint | grep -q /dev/md; do umount $mntpoint || sleep 1 done mdconfig -d -u $mdstart rm /tmp/fifo3 /tmp/fifo3.c Index: user/pho/stress2/misc/graid1_2.sh =================================================================== --- user/pho/stress2/misc/graid1_2.sh (revision 317556) +++ user/pho/stress2/misc/graid1_2.sh (revision 317557) @@ -1,132 +1,132 @@ #!/bin/sh # # Copyright (c) 2017 Dell EMC Isilon # All rights reserved. # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions # are met: # 1. Redistributions of source code must retain the above copyright # notice, this list of conditions and the following disclaimer. # 2. Redistributions in binary form must reproduce the above copyright # notice, this list of conditions and the following disclaimer in the # documentation and/or other materials provided with the distribution. # # THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND # ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE # ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE # FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL # DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS # OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) # HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT # LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY # OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF # SUCH DAMAGE. # # $FreeBSD$ # # Test scenario by Mark Johnston # "physwr DL /tmp/graid1_2 /dev/mirror/test" seen. # Fixed by r307691. [ `id -u ` -ne 0 ] && echo "Must be root!" && exit 1 . ../default.cfg dir=/tmp odir=`pwd` cd $dir sed '1,/^EOF/d' < $odir/$0 > $dir/graid1_2.c mycc -o graid1_2 -Wall -Wextra -O0 -g graid1_2.c || exit 1 rm -f graid1_2.c cd $odir gmirror load > /dev/null 2>&1 && unload=1 [ -c /dev/mirror/test ] && { gmirror stop test; gmirror destroy test; } old=`sysctl -n kern.geom.mirror.debug` sysctl kern.geom.mirror.debug=-1 | grep -q -- -1 || sysctl kern.geom.mirror.debug=$old > /dev/null md1=$mdstart md2=$((mdstart + 1)) s=0 size=$((128 * 1024)) for u in $md1 $md2; do dd if=/dev/zero of=/tmp/graid1_2_di$u bs=$size count=1 2>&1 | \ egrep -v "records|transferred" [ -c /dev/md$u ] && mdconfig -d -u $u mdconfig -a -t vnode -f /tmp/graid1_2_di$u -u $u done gmirror label test /dev/md$md1 /dev/md$md2 || exit 1 [ -c /dev/mirror/test ] || exit 1 for i in `jot 150`; do /tmp/graid1_2 /dev/mirror/test; done & sleep 5 start=`date '+%s'` while [ $((`date '+%s'` - start)) -lt 300 ]; do gmirror rebuild test /dev/md$md1 sleep 2 n=0 - while ps -l | grep -v grep | grep graid1_2 | grep -q D; do + while ps -lx | grep -v grep | grep graid1_2 | grep -q D; do opid=$pid pid=`pgrep graid1_2` [ -z "$pid" -o "$pid" != "$opid" ] && n=0 sleep 1 n=$((n + 1)) if [ $n -gt 180 ]; then echo FAIL - ps -l | grep -v grep | grep graid1_2 | grep D + ps -lx | grep -v grep | grep graid1_2 | grep D exit 1 fi done done kill $! 2>/dev/null pkill graid1_2 wait while mount | grep $mntpoint | grep -q /mirror/; do umount $mntpoint || sleep 1 done gmirror stop test || s=2 [ $unload ] && gmirror unload for u in $md3 $md2 $md1; do mdconfig -d -u $u || s=4 done rm -d /tmp/graid1_2 /tmp/graid1_2_di? exit $s EOF /* Write last sector on disk */ #include #include #include #include #include #include static char buf[512]; int main(int argc __unused, char *argv[]) { time_t start; int fd; if ((fd = open(argv[1], O_RDWR)) == -1) err(1, "open(%s)", argv[1]); start = time(NULL); while (time(NULL) - start < 2) { if (lseek(fd, 254 * sizeof(buf), SEEK_SET) == -1) err(1, "seek"); if (write(fd, buf, sizeof(buf)) != sizeof(buf)) err(1, "write"); } close(fd); return (0); } Index: user/pho/stress2/misc/mlockall.sh =================================================================== --- user/pho/stress2/misc/mlockall.sh (revision 317556) +++ user/pho/stress2/misc/mlockall.sh (revision 317557) @@ -1,81 +1,82 @@ #!/bin/sh # # Copyright (c) 2009 Peter Holm # All rights reserved. # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions # are met: # 1. Redistributions of source code must retain the above copyright # notice, this list of conditions and the following disclaimer. # 2. Redistributions in binary form must reproduce the above copyright # notice, this list of conditions and the following disclaimer in the # documentation and/or other materials provided with the distribution. # # THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND # ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE # ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE # FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL # DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS # OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) # HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT # LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY # OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF # SUCH DAMAGE. # # $FreeBSD$ # # "panic: swap_reserved < decr" seen. Fixed in r195329 . ../default.cfg [ `id -u ` -ne 0 ] && echo "Must be root!" && exit 1 odir=`pwd` cd /tmp sed '1,/^EOF/d' < $odir/$0 > mlockall.c mycc -o mlockall -Wall mlockall.c rm -f mlockall.c for i in `jot 10`; do /tmp/mlockall & sleep 1 - ps | grep /tmp/mlockall | grep -v grep | awk '{print $1}' | while read pid; do + ps -x | grep /tmp/mlockall | grep -v grep | awk '{print $1}' | \ + while read pid; do kill -2 $pid kill -9 $pid done done rm -f /tmp/mlockall exit EOF #include #include #include #include #include #include void child(void) { if (mlockall(MCL_CURRENT | MCL_FUTURE) == -1) err(1, "mlockall(MCL_CURRENT | MCL_FUTURE)"); fork(); sleep(60); } int main(int argc, char **argv) { int status; if (fork() == 0) child(); wait(&status); return (0); } Index: user/pho/stress2/misc/mountro.sh =================================================================== --- user/pho/stress2/misc/mountro.sh (revision 317556) +++ user/pho/stress2/misc/mountro.sh (revision 317557) @@ -1,68 +1,68 @@ #!/bin/sh # # Copyright (c) 2008-2011 Peter Holm # All rights reserved. # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions # are met: # 1. Redistributions of source code must retain the above copyright # notice, this list of conditions and the following disclaimer. # 2. Redistributions in binary form must reproduce the above copyright # notice, this list of conditions and the following disclaimer in the # documentation and/or other materials provided with the distribution. # # THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND # ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE # ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE # FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL # DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS # OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) # HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT # LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY # OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF # SUCH DAMAGE. # # $FreeBSD$ # . ../default.cfg [ `id -u ` -ne 0 ] && echo "Must be root!" && exit 1 D=$diskimage dede $D 1m 128 || exit mount | grep "$mntpoint" | grep -q /md && umount -f ${mntpoint} mdconfig -l | grep -q ${mdstart} && mdconfig -d -u $mdstart mdconfig -a -t vnode -f $D -u $mdstart || { rm -f $D; exit 1; } bsdlabel -w md${mdstart} auto newfs $newfs_flags md${mdstart}${part} > /dev/null 2>&1 mount /dev/md${mdstart}${part} $mntpoint mkdir ${mntpoint}/stressX chmod 777 ${mntpoint}/stressX export RUNDIR=${mntpoint}/stressX export runRUNTIME=4m (cd ..; ./run.sh disk.cfg > /dev/null 2>&1) & sleep 30 for i in `jot 10`; do mount $mntpoint -u -o ro > /dev/null 2>&1 sleep 3 mount $mntpoint -u -o rw > /dev/null 2>&1 sleep 3 done df -i $mntpoint umount -f $mntpoint > /dev/null 2>&1 mdconfig -d -u $mdstart rm -f $D -kill `ps | grep run.sh | grep -v grep | awk '{print $1}'` +kill `ps -x | grep run.sh | grep -v grep | awk '{print $1}'` wait Index: user/pho/stress2/misc/ptrace10.sh =================================================================== --- user/pho/stress2/misc/ptrace10.sh (revision 317556) +++ user/pho/stress2/misc/ptrace10.sh (revision 317557) @@ -1,136 +1,136 @@ #!/bin/sh # ptrace(2) test scenario by Mark Johnston # https://people.freebsd.org/~markj/ptrace_stop_mt.c # Fixed by r303423. # stopped on signal 17 after detach # UID PID PPID CPU PRI NI VSZ RSS MWCHAN STAT TT TIME COMMAND # 1001 47125 62778 0 52 0 6568 2456 wait S+ 2 0:00.01 /bin/sh ./ptrace10.sh # 1001 47146 47125 0 23 0 6108 1928 nanslp S+ 2 0:00.00 ./ptrace10 # 1001 47148 47146 0 24 0 6240 1932 - T+ 2 0:00.00 ./ptrace10 # 1001 47148 47146 0 24 0 6240 1932 - T+ 2 0:00.00 ./ptrace10 . ../default.cfg cd /tmp cat > ptrace10.c < #include #include #include #include #include #include #include #include static void sighup(int sig __unused) { } static void sleep_forever(void) { while (1) sleep(1); } static void * thread(void *arg __unused) { sleep_forever(); return (NULL); } int main(void) { struct sigaction act; sigset_t set; pthread_t t; pid_t pid, ret; int e, try, limit, r, status; e = 0; pid = fork(); if (pid < 0) err(1, "fork"); if (pid == 0) { act.sa_handler = sighup; act.sa_flags = 0; sigemptyset(&act.sa_mask); if (sigaction(SIGHUP, &act, NULL) != 0) err(1, "sigaction"); r = pthread_create(&t, NULL, thread, NULL); if (r != 0) errc(1, r, "pthread_create"); /* Force SIGHUP to be delivered to the new thread. */ sigemptyset(&set); sigaddset(&set, SIGHUP); r = pthread_sigmask(SIG_BLOCK, &set, NULL); if (r != 0) errc(1, r, "pthread_sigmask"); sleep_forever(); } else { sleep(1); /* give the child a chance to set itself up */ limit = 100; for (try = 1; try <= limit; try++) { // printf("attempt %d of %d\n", try, limit); if (kill(pid, SIGHUP) != 0) err(1, "kill(SIGHUP)"); if (ptrace(PT_ATTACH, pid, NULL, 0) != 0) err(1, "ptrace(PT_ATTACH)"); if (waitpid(pid, &status, WUNTRACED) != pid) err(1, "waitpid 1"); if (!WIFSTOPPED(status)) errx(1, "unexpected status %d after PT_ATTACH", status); if (ptrace(PT_DETACH, pid, NULL, 0) != 0) err(1, "ptrace(PT_DETACH)"); sleep(1); ret = waitpid(pid, &status, WUNTRACED | WNOHANG); if (ret < 0) err(1, "waitpid"); if (ret == 0) continue; if (!WIFSTOPPED(status)) errx(1, "unexpected status %d after PT_DETACH", status); printf("stopped on signal %d after detach\n", WSTOPSIG(status)); e = 1; // sleep_forever(); break; } } kill(pid, SIGINT); return (e); } EOF mycc -o ptrace10 -Wall -Wextra -O2 -g ptrace10.c -lpthread || exit 1 rm ptrace10.c ./ptrace10 s=$? if [ $s -ne 0 ]; then - ps -lH | grep -v grep | egrep "UID|ptrace10" + ps -lxH | grep -v grep | egrep "UID|ptrace10" while pgrep -q ptrace10; do pkill -9 ptrace10 done fi wait rm -f ptrace10 exit $s Index: user/pho/stress2/misc/truncate2.sh =================================================================== --- user/pho/stress2/misc/truncate2.sh (revision 317556) +++ user/pho/stress2/misc/truncate2.sh (revision 317557) @@ -1,101 +1,101 @@ #!/bin/sh # # Copyright (c) 2009 Peter Holm # All rights reserved. # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions # are met: # 1. Redistributions of source code must retain the above copyright # notice, this list of conditions and the following disclaimer. # 2. Redistributions in binary form must reproduce the above copyright # notice, this list of conditions and the following disclaimer in the # documentation and/or other materials provided with the distribution. # # THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND # ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE # ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE # FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL # DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS # OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) # HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT # LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY # OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF # SUCH DAMAGE. # # $FreeBSD$ # . ../default.cfg here=`pwd` cd /tmp sed '1,/^EOF/d' < $here/$0 > truncate2.c mycc -o truncate2 -Wall -O2 truncate2.c rm -f truncate2.c [ -d $RUNDIR ] || mkdir -p $RUNDIR cd $RUNDIR /tmp/truncate2 & sleep 1 -while ps | grep -v grep | egrep -q "truncate2$"; do +while ps -x | grep -v grep | egrep -q "truncate2$"; do $here/../testcases/swap/swap -t 2m -i 20 done rm -f /tmp/truncate2 exit 0 EOF #include #include #include #include #include #include #define SIZ 512 char buf[SIZ]; void test(void) { int fd[10], i, j; char name[128]; off_t len; for (j = 0; j < 10; j++) { sprintf(name, "%05d.%05d", getpid(), j); fd[j] = open(name, O_WRONLY | O_CREAT | O_APPEND, 0666); if (fd[j] == -1) err(1, "%s", name); unlink(name); } for (i = 0; i < 100; i++) { for (j = 0; j < 10; j++) { if (write(fd[j], buf, 2) != 2) err(1, "write"); len = arc4random() % 1024 * 1024; if (ftruncate(fd[j], len) == -1) err(1, "ftruncate"); } } exit(0); } int main(int argc, char **argv) { int i, status; for (i = 0; i < 20; i++) { if (fork() == 0) test(); } for (i = 0; i < 20; i++) wait(&status); return (0); } Index: user/pho/stress2/misc/truss.sh =================================================================== --- user/pho/stress2/misc/truss.sh (revision 317556) +++ user/pho/stress2/misc/truss.sh (revision 317557) @@ -1,130 +1,130 @@ #!/bin/sh # # Copyright (c) 2015 EMC Corp. # All rights reserved. # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions # are met: # 1. Redistributions of source code must retain the above copyright # notice, this list of conditions and the following disclaimer. # 2. Redistributions in binary form must reproduce the above copyright # notice, this list of conditions and the following disclaimer in the # documentation and/or other materials provided with the distribution. # # THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND # ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE # ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE # FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL # DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS # OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) # HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT # LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY # OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF # SUCH DAMAGE. # # $FreeBSD$ # # truss(1) of a multithreaded program. # FAIL # 0 90968 90933 0 52 0 6028 0 wait IW+ 1 0:00,00 truss /tmp/ttruss # 0 90970 90968 0 52 0 6436 1560 uwrlck IX+ 1 0:00,00 /tmp/ttruss # $ procstat -k 90970 # PID TID COMM TDNAME KSTACK # 90970 101244 ttruss - mi_switch sleepq_switch # sleepq_catch_signals sleepq_wait_sig _sleep umtxq_sleep # do_rw_wrlock __umtx_op_rw_wrlock syscall Xint0x80_syscall # $ # Only seen during testing of a WiP ptrace(2) patch. . ../default.cfg dir=/tmp odir=`pwd` cd $dir sed '1,/^EOF/d' < $odir/$0 > $dir/ttruss.c mycc -o ttruss -Wall -Wextra -O0 -g ttruss.c -lpthread || exit 1 rm -f ttruss.c # VM pressure is not mandatory, but shortens the time to failure. daemon sh -c \ "(cd $odir/../testcases/swap; ./swap -t 6m -i 20 -k -l 100)" > \ /dev/null sleep .5 for i in `jot 30`; do truss /tmp/ttruss 10 > /dev/null 2>&1 & sleep 11 - if ps -l | grep -v grep | grep -q uwrlck; then + if ps -lx | grep -v grep | grep -q uwrlck; then echo FAIL ps -lH | egrep -v "grep|truss.sh" | grep truss while pkill -9 swap; do : done exit 1 fi wait done while pkill -9 swap; do : done sleep 2 if pgrep -q ttruss; then echo FAIL - ps -lH | grep -v grep | grep ttruss + ps -lxH | grep -v grep | grep ttruss s=1 fi rm -rf /tmp/ttruss /tmp/ttruss.core exit $s EOF #include #include #include #include #include #include #include #include #include #define THREADS 16 static void * t1(void *data __unused) { return (NULL); } int main(int argc, char *argv[]) { pthread_t tid[THREADS]; time_t start; int i, rc, runtime; if (argc != 2) errx(1, "Usage: %s ", argv[0]); runtime = atoi(argv[1]); start = time(NULL); while ((time(NULL) - start) < runtime) { for (i = 0; i < THREADS; i++) { if ((rc = pthread_create(&tid[i], NULL, t1, NULL)) != 0) errc(1, rc, "pthread_create"); } for (i = 0; i < THREADS; i++) { if ((rc = pthread_join(tid[i], NULL)) != 0) errc(1, rc, "pthread_join"); } } return (0); } Index: user/pho/stress2/misc/vfork.sh =================================================================== --- user/pho/stress2/misc/vfork.sh (revision 317556) +++ user/pho/stress2/misc/vfork.sh (revision 317557) @@ -1,131 +1,133 @@ #!/bin/sh # # Copyright (c) 2013 EMC Corp. # All rights reserved. # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions # are met: # 1. Redistributions of source code must retain the above copyright # notice, this list of conditions and the following disclaimer. # 2. Redistributions in binary form must reproduce the above copyright # notice, this list of conditions and the following disclaimer in the # documentation and/or other materials provided with the distribution. # # THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND # ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE # ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE # FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL # DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS # OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) # HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT # LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY # OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF # SUCH DAMAGE. # # $FreeBSD$ # # Regression test for r246484. # "panic: failed to set signal flags for ast p ... fl 4" seen. # Fixed in r302999. . ../default.cfg cd /tmp cat > vfork1.c <<- EOF #include #include #include int main(void) { pid_t pid; fprintf(stderr, "%d\n", getpid()); if ((pid = vfork()) == 0) { #if 0 if (ptrace(PT_TRACE_ME, 0, 0, 0) == -1) err(1, "PT_TRACEME"); #endif sleep(30); _exit(0); } if (pid == -1) err(1, "vfork"); return (0); } EOF mycc -o vfork1 -Wall -Wextra -g vfork1.c rm vfork1.c cat > vfork2.c <<- EOF #include #include #include #include #include #include #include #include #include #include #include #include int main(int argc, char **argv) { pid_t pid, rpid; struct rusage ru; int status; if (argc != 2) errx(1, "Usage: %s ", argv[0]); pid = atoi(argv[1]); if (pid == -1) err(1, "fork()"); if (ptrace(PT_ATTACH, pid, NULL, 0) == -1) err(1, "ptrace(%d) attach", pid); if (wait(NULL) == -1) err(1, "wait"); bzero(&ru, sizeof(ru)); usleep(2000); if ((rpid = wait4(-1, &status, WNOHANG, &ru)) == -1) { - err(1, "OK wait4"); + err(0, "OK wait4"); } if (rpid == 0) { // fprintf(stderr, "No rusage info.\n"); if (ptrace(PT_DETACH, pid, NULL, 0) == -1) err(1, "ptrace(%d) detach", pid); if (wait(&status) == -1) err(1, "wait"); } else { fprintf(stderr, "FAIL Got unexpected rusage.\n"); if (ru.ru_utime.tv_sec != 0) fprintf(stderr, "FAIL tv_sec\n"); } if (status != 0x4000) fprintf(stderr, "FAIL Child exit status 0x%x\n", status); return (0); } EOF mycc -o vfork2 -Wall -Wextra -g vfork2.c rm vfork2.c ./vfork1 & sleep .2 -childpid=`ps -l | grep -v grep | grep vfork1 | +childpid=`ps -lx | grep -v grep | grep vfork1 | tail -1 | grep nanslp | awk '{print $2}'` # Seen before fix: # failed to set signal flags properly for ast() ./vfork2 $childpid +s=$? rm -f vfork1 vfork2 +exit $s