Index: user/pho/stress2/misc/fifo2.sh =================================================================== --- user/pho/stress2/misc/fifo2.sh (revision 285601) +++ user/pho/stress2/misc/fifo2.sh (revision 285602) @@ -1,215 +1,215 @@ #!/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$ # # Page fault seen # http://people.freebsd.org/~pho/stress/log/kostik654.txt # Fixed by r259521. [ `id -u ` -ne 0 ] && echo "Must be root!" && exit 1 . ../default.cfg killall 2>&1 | grep -q q && q="-q" odir=`pwd` cd /tmp sed '1,/^EOF/d' < $odir/$0 > fifo2.c rm -f /tmp/fifo2 mycc -o fifo2 -Wall -Wextra -O2 -g fifo2.c -lpthread || exit 1 rm -f fifo2.c mount | grep $mntpoint | grep -q /dev/md && umount -f $mntpoint mdconfig -l | grep -q md$mdstart && mdconfig -d -u $mdstart mdconfig -a -t swap -s 2g -u $mdstart || exit 1 bsdlabel -w md$mdstart auto newfs $newfs_flags md${mdstart}$part > /dev/null mount /dev/md${mdstart}$part $mntpoint chmod 777 $mntpoint mkfifo $mntpoint/f chmod 777 $mntpoint/f sleeptime=12 st=`date '+%s'` while [ $((`date '+%s'` - st)) -lt $((10 * sleeptime)) ]; do (cd $mntpoint; /tmp/fifo2) & start=`date '+%s'` while [ $((`date '+%s'` - start)) -lt $sleeptime ]; do ps aux | grep -v grep | egrep -q "fifo2$" || break sleep .5 done if ps aux | grep -v grep | egrep -q "fifo2$"; then killall $q fifo2 ps aux | grep -v grep | egrep -q "fifo2 " && killall $q -9 fifo2 fi wait done killall $q -9 fifo2 ps aux | grep -v grep | egrep -v "\.sh" | grep -q fifo2 && killall $q -9 fifo2 for i in `jot 10`; do mount | grep -q md${mdstart}$part && \ umount $mntpoint > /dev/null 2>&1 && mdconfig -d -u $mdstart && break sleep 10 done mount | grep -q md${mdstart}$part && echo "umount $mntpoint failed" rm -f /tmp/fifo2 exit EOF #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #define N (128 * 1024 / (int)sizeof(u_int32_t)) u_int32_t r[N]; static void hand(int i __unused) { /* handler */ _exit(1); } unsigned long makearg(void) { unsigned int i; unsigned long val; val = arc4random(); i = arc4random() % 100; if (i < 20) val = val & 0xff; if (i >= 20 && i < 40) val = val & 0xffff; if (i >= 40 && i < 60) val = (unsigned long)(r) | (val & 0xffff); #if defined(__LP64__) if (i >= 60) { val = (val << 32) | arc4random(); if (i > 80) val = val & 0x00007fffffffffffUL; } #endif return(val); } void * calls(void *arg __unused) { int i, num; unsigned long arg1, arg2, arg3, arg4, arg5, arg6, arg7; for (i = 0;; i++) { arg1 = (unsigned long)(void *)"f"; arg2 = makearg(); arg3 = makearg(); arg4 = makearg(); arg5 = makearg(); arg6 = makearg(); arg7 = makearg(); #if 0 fprintf(stderr, "%2d : syscall(%3d, %lx, %lx, %lx, %lx, %lx, %lx, %lx)\n", i, SYS_open, arg1, arg2, arg3, arg4, arg5, arg6, arg7); usleep(100000); #endif alarm(1); syscall(SYS_open, arg1, arg2, arg3, arg4, arg5, arg6, arg7); num = 0; } return (0); } int main(void) { struct passwd *pw; struct rlimit limit; pthread_t cp[50]; time_t start; - int j; + int e, j; if ((pw = getpwnam("nobody")) == NULL) err(1, "no such user: nobody"); if (setgroups(1, &pw->pw_gid) || setegid(pw->pw_gid) || setgid(pw->pw_gid) || seteuid(pw->pw_uid) || setuid(pw->pw_uid)) err(1, "Can't drop privileges to \"nobody\""); endpwent(); limit.rlim_cur = limit.rlim_max = 1000; if (setrlimit(RLIMIT_NPTS, &limit) < 0) err(1, "setrlimit"); signal(SIGALRM, hand); signal(SIGILL, hand); signal(SIGFPE, hand); signal(SIGSEGV, hand); signal(SIGBUS, hand); signal(SIGURG, hand); signal(SIGSYS, hand); signal(SIGTRAP, hand); start = time(NULL); while ((time(NULL) - start) < 120) { if (fork() == 0) { arc4random_stir(); for (j = 0; j < 1; j++) - if (pthread_create(&cp[j], NULL, calls, NULL) != 0) - perror("pthread_create"); + if ((e = pthread_create(&cp[j], NULL, calls, NULL)) != 0) + errc(1, e,"pthread_create"); for (j = 0; j < 1; j++) pthread_join(cp[j], NULL); _exit(0); } wait(NULL); } return (0); } Index: user/pho/stress2/misc/kevent6.sh =================================================================== --- user/pho/stress2/misc/kevent6.sh (revision 285601) +++ user/pho/stress2/misc/kevent6.sh (revision 285602) @@ -1,156 +1,156 @@ #!/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$ # # "Sleeping thread (tid 101094, pid 13104) owns a non-sleepable lock" seen. # Fixed in r255798. . ../default.cfg odir=`pwd` cd /tmp sed '1,/^EOF/d' < $odir/$0 > kevent6.c mycc -o kevent6 -Wall -Wextra -O2 -g kevent6.c -lpthread || exit 1 rm -f kevent6.c cd $odir mount | grep "on $mntpoint " | grep -q md$mdstart && umount -f $mntpoint mdconfig -l | grep -q $mdstart && mdconfig -d -u $mdstart mdconfig -a -t swap -s 2g -u ${mdstart} bsdlabel -w md$mdstart auto newfs $newfs_flags md${mdstart}$part > /dev/null mount /dev/md${mdstart}$part $mntpoint chmod 777 $mntpoint su $testuser -c "(cd $mntpoint; /tmp/kevent6)" while mount | grep -q $mntpoint; do umount $mntpoint || sleep 1 done mdconfig -d -u $mdstart rm -f /tmp/kevent6 exit EOF #include #include #include #include #include #include #include #include #include #include #include #include #include #include #define PARALLEL 8 static char path[80]; int fd; void * spin(void *arg __unused) { int i; for (i= 0;; i++) { snprintf(path, sizeof(path), "file.%06d.%d", getpid(), i); if ((fd = open(path, O_CREAT | O_TRUNC | O_RDWR, 0622)) == -1) err(1, "creat()"); close(fd); usleep(10000); fd = 0; unlink(path); } return (NULL); } void * test(void *arg __unused) { int kq; int i, n; struct kevent ev; struct timespec ts; for (i = 0; i < 500000; i++) { if ((kq = kqueue()) < 0) err(1, "kqueue()"); n = 0; memset(&ev, 0, sizeof(ev)); EV_SET(&ev, fd, EVFILT_VNODE, EV_ADD | EV_ENABLE | EV_CLEAR, NOTE_DELETE|NOTE_RENAME|NOTE_EXTEND, 0, 0); n++; if (kevent(kq, &ev, n, NULL, 0, NULL) < 0) { close(kq); continue; } memset(&ev, 0, sizeof(ev)); ts.tv_sec = 0; ts.tv_nsec = 1000000; if ((n = kevent(kq, NULL, 0, &ev, 1, &ts)) == -1) err(1, "kevent()"); close(kq); } return (NULL); } int main(void) { - int i; pthread_t cp[PARALLEL], sp; + int e, i; - if (pthread_create(&sp, NULL, spin, NULL) != 0) - perror("pthread_create"); + if ((e = pthread_create(&sp, NULL, spin, NULL)) != 0) + errc(1, e, "pthread_create"); for (i = 0; i < PARALLEL; i++) { - if (pthread_create(&cp[i], NULL, test, NULL) != 0) - perror("pthread_create"); + if ((e = pthread_create(&cp[i], NULL, test, NULL)) != 0) + errc(1, e, "pthread_create"); } for (i = 0; i < PARALLEL; i++) pthread_join(cp[i], NULL); close(fd); return (0); } Index: user/pho/stress2/misc/kevent7.sh =================================================================== --- user/pho/stress2/misc/kevent7.sh (revision 285601) +++ user/pho/stress2/misc/kevent7.sh (revision 285602) @@ -1,265 +1,265 @@ #!/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$ # # Threaded syscall(2) fuzz test inspired by the iknowthis test suite # by Tavis Ormandy # kevent(2) with random arguments. # Spinning threads seen. # Fixed in r255877. [ `id -u ` -ne 0 ] && echo "Must be root!" && exit 1 . ../default.cfg ulimit -t 200 odir=`pwd` cd /tmp sed '1,/^EOF/d' < $odir/$0 > kevent7.c rm -f /tmp/kevent7 mycc -o kevent7 -Wall -Wextra -O2 -g kevent7.c -lpthread || exit 1 rm -f kevent7.c mount | grep $mntpoint | grep -q /dev/md && umount -f $mntpoint mdconfig -l | grep -q md$mdstart && mdconfig -d -u $mdstart mdconfig -a -t swap -s 2g -u $mdstart || exit 1 bsdlabel -w md$mdstart auto newfs $newfs_flags md${mdstart}$part > /dev/null mount /dev/md${mdstart}$part $mntpoint chmod 777 $mntpoint for i in `jot 5`; do (cd $mntpoint; /tmp/kevent7 $* < /dev/null) & sleep 60 killall -9 kevent7 done for i in `jot 5`; do mount | grep -q md${mdstart}$part && \ umount $mntpoint && mdconfig -d -u $mdstart && break sleep 10 done if mount | grep -q md${mdstart}$part; then fstat $mntpoint echo "umount $mntpoint failed" exit 1 fi rm -f /tmp/kevent7 exit EOF #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include int fd[900], fds[2], socketpr[2]; #define N (128 * 1024 / (int)sizeof(u_int32_t)) u_int32_t r[N]; int syscallno; static void hand(int i __unused) { /* handler */ _exit(1); } unsigned long makearg(void) { unsigned int i; unsigned long val; val = arc4random(); i = arc4random() % 100; if (i < 20) val = val & 0xff; if (i >= 20 && i < 40) val = val & 0xffff; if (i >= 40 && i < 60) val = (unsigned long)(r) | (val & 0xffff); #if defined(__LP64__) if (i >= 60) { val = (val << 32) | arc4random(); if (i > 80) val = val & 0x00007fffffffffffUL; } #endif return(val); } void * test(void *arg __unused) { FTS *fts; FTSENT *p; int ftsoptions; char *args[5]; int i; ftsoptions = FTS_PHYSICAL; args[0] = "/dev"; args[1] = "/proc"; args[2] = "/usr/compat/linux/proc"; args[3] = "."; args[4] = 0; for (;;) { for (i = 0; i < N; i++) r[i] = arc4random(); if ((fts = fts_open(args, ftsoptions, NULL)) == NULL) err(1, "fts_open"); i = 0; while ((p = fts_read(fts)) != NULL) { if (fd[i] > 0) close(fd[i]); if ((fd[i] = open(p->fts_path, O_RDWR)) == -1) if ((fd[i] = open(p->fts_path, O_WRONLY)) == -1) if ((fd[i] = open(p->fts_path, O_RDONLY)) == -1) continue; i++; i = i % 900; } if (fts_close(fts) == -1) if (errno != ENOTDIR) warn("fts_close()"); if (pipe(fds) == -1) err(1, "pipe()"); if (socketpair(PF_UNIX, SOCK_SEQPACKET, 0, socketpr) == -1) err(1, "socketpair()"); sleep(1); close(socketpr[0]); close(socketpr[1]); close(fds[0]); close(fds[1]); } return(0); } void * calls(void *arg __unused) { int i, kq, num; unsigned long arg1, arg2, arg3, arg4, arg5, arg6, arg7; if ((kq = kqueue()) < 0) err(1, "kqueue()"); for (i = 0;; i++) { if (i == 0) usleep(1000); num = syscallno; arg1 = makearg(); arg2 = makearg(); arg3 = makearg(); arg4 = makearg(); arg5 = makearg(); arg6 = makearg(); arg7 = makearg(); #if 0 fprintf(stderr, "%2d : syscall(%3d, %lx, %lx, %lx, %lx, %lx, %lx, %lx)\n", i, num, arg1, arg2, arg3, arg4, arg5, arg6, arg7); #endif alarm(1); syscall(num, arg1, arg2, arg3, arg4, arg5, arg6, arg7); num = 0; } close(kq); return (0); } int main(void) { struct passwd *pw; time_t start; pthread_t rp, cp[50]; - int j; + int e, j; if ((pw = getpwnam("nobody")) == NULL) err(1, "no such user: nobody"); if (setgroups(1, &pw->pw_gid) || setegid(pw->pw_gid) || setgid(pw->pw_gid) || seteuid(pw->pw_uid) || setuid(pw->pw_uid)) err(1, "Can't drop privileges to \"nobody\""); endpwent(); signal(SIGALRM, hand); signal(SIGILL, hand); signal(SIGFPE, hand); signal(SIGSEGV, hand); signal(SIGBUS, hand); signal(SIGURG, hand); signal(SIGSYS, hand); signal(SIGTRAP, hand); syscallno = SYS_kevent; start = time(NULL); while (time(NULL) - start < 120) { if (fork() == 0) { arc4random_stir(); - if (pthread_create(&rp, NULL, test, NULL) != 0) - perror("pthread_create"); + if ((e = pthread_create(&rp, NULL, test, NULL)) != 0) + errc(1, e, "pthread_create"); usleep(1000); for (j = 0; j < 50; j++) - if (pthread_create(&cp[j], NULL, calls, NULL) != 0) - perror("pthread_create"); + if ((e = pthread_create(&cp[j], NULL, calls, NULL)) != 0) + errc(1, e, "pthread_create"); for (j = 0; j < 50; j++) pthread_join(cp[j], NULL); _exit(0); } wait(NULL); } return (0); } Index: user/pho/stress2/misc/kevent8.sh =================================================================== --- user/pho/stress2/misc/kevent8.sh (revision 285601) +++ user/pho/stress2/misc/kevent8.sh (revision 285602) @@ -1,161 +1,161 @@ #!/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$ # Out of VM seen due to missing close of kqueue handle. # Fixed in 256849 . ../default.cfg ulimit -k 10000 || { echo FAIL; exit 1; } odir=`pwd` cd /tmp sed '1,/^EOF/d' < $odir/$0 > kevent8.c mycc -o kevent8 -Wall -Wextra -O2 -g kevent8.c -lpthread || exit 1 rm -f kevent8.c cd $odir mount | grep "on $mntpoint " | grep -q md$mdstart && umount -f $mntpoint mdconfig -l | grep -q $mdstart && mdconfig -d -u $mdstart mdconfig -a -t swap -s 2g -u ${mdstart} bsdlabel -w md$mdstart auto newfs $newfs_flags md${mdstart}$part > /dev/null mount /dev/md${mdstart}$part $mntpoint chmod 777 $mntpoint su $testuser -c "(cd $mntpoint; /tmp/kevent8)" & sleep 99 umount -f $mntpoint pkill kevent8 wait while mount | grep -q $mntpoint; do umount $mntpoint || sleep 1 done mdconfig -d -u $mdstart rm -f /tmp/kevent8 exit EOF #include #include #include #include #include #include #include #include #include #include #include #include #include #include #define PARALLEL 64 static char path[80]; int fd; void * spin(void *arg __unused) { int i; setproctitle("spin"); for (i= 0;; i++) { snprintf(path, sizeof(path), "file.%06d.%d", getpid(), i); if ((fd = open(path, O_CREAT | O_TRUNC | O_RDWR, 0622)) == -1) err(1, "creat()"); close(fd); fd = 0; unlink(path); } return (NULL); } void * test(void *arg __unused) { int kq; int i, n; struct kevent ev; struct timespec ts; for (i = 0; i < 500000; i++) { if ((kq = kqueue()) < 0) if (errno != ENOMEM) err(1, "kqueue()"); n = 0; memset(&ev, 0, sizeof(ev)); EV_SET(&ev, fd, EVFILT_VNODE, EV_ADD | EV_ENABLE | EV_CLEAR, NOTE_DELETE|NOTE_RENAME|NOTE_EXTEND, 0, 0); n++; if (kevent(kq, &ev, n, NULL, 0, NULL) < 0) continue; /* Note: missing close(kq)! */ memset(&ev, 0, sizeof(ev)); ts.tv_sec = 0; ts.tv_nsec = 1000000; if ((n = kevent(kq, NULL, 0, &ev, 1, &ts)) == -1) err(1, "kevent()"); close(kq); } return (NULL); } int main(void) { - int i; pthread_t cp[PARALLEL], sp; + int e, i; - if (pthread_create(&sp, NULL, spin, NULL) != 0) - perror("pthread_create"); + if ((e = pthread_create(&sp, NULL, spin, NULL)) != 0) + errc(1, e, "pthread_create"); for (i = 0; i < PARALLEL; i++) { - if (pthread_create(&cp[i], NULL, test, NULL) != 0) - perror("pthread_create"); + if ((e = pthread_create(&cp[i], NULL, test, NULL)) != 0) + errc(1, e, "pthread_create"); } for (i = 0; i < PARALLEL; i++) pthread_join(cp[i], NULL); close(fd); return (0); } Index: user/pho/stress2/misc/mlockall3.sh =================================================================== --- user/pho/stress2/misc/mlockall3.sh (revision 285601) +++ user/pho/stress2/misc/mlockall3.sh (revision 285602) @@ -1,170 +1,170 @@ #!/bin/sh # # Copyright (c) 2013 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$ # # mlockall(2) test scenario. # "panic: vm_page_unwire: page xxx's wire count is zero" seen. # http://people.freebsd.org/~pho/stress/log/mlockall.txt [ `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/mlockall3.c mycc -o mlockall3 -Wall -Wextra mlockall3.c -lpthread || exit 1 rm -f mlockall3.c cd $odir /tmp/mlockall3 killall mlockall3 > /dev/null 2>&1 rm -f /tmp/mlockall3 exit EOF #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #define N (128 * 1024 / (int)sizeof(u_int32_t)) u_int32_t r[N]; static void hand(int i __unused) { /* handler */ _exit(1); } unsigned long makearg(void) { unsigned int i; unsigned long val; val = arc4random(); i = arc4random() % 100; if (i < 20) val = val & 0xff; if (i >= 20 && i < 40) val = val & 0xffff; if (i >= 40 && i < 60) val = (unsigned long)(r) | (val & 0xffff); #if defined(__LP64__) if (i >= 60) { val = (val << 32) | arc4random(); if (i > 80) val = val & 0x00007fffffffffffUL; } #endif return(val); } void * calls(void *arg __unused) { int i; unsigned long arg1, arg2, arg3; usleep(1000); for (i = 0; i < 500; i++) { arg1 = makearg(); arg2 = makearg(); arg3 = makearg(); alarm(1); syscall(SYS_mlockall, arg1, arg2, arg3); } return (0); } int main(void) { struct passwd *pw; pid_t pid; pthread_t cp[50]; - int i, j; + int e, i, j; if ((pw = getpwnam("nobody")) == NULL) err(1, "no such user: nobody"); if (setgroups(1, &pw->pw_gid) || setegid(pw->pw_gid) || setgid(pw->pw_gid) || seteuid(pw->pw_uid) || setuid(pw->pw_uid)) err(1, "Can't drop privileges to \"nobody\""); endpwent(); signal(SIGALRM, hand); signal(SIGILL, hand); signal(SIGFPE, hand); signal(SIGSEGV, hand); signal(SIGBUS, hand); signal(SIGURG, hand); signal(SIGSYS, hand); signal(SIGTRAP, hand); alarm(180); for (i = 0; i < 8000; i++) { if ((pid = fork()) == 0) { arc4random_stir(); for (j = 0; j < N; j++) r[j] = arc4random(); for (j = 0; j < 50; j++) - if (pthread_create(&cp[j], NULL, calls, NULL) != 0) - perror("pthread_create"); + if ((e = pthread_create(&cp[j], NULL, calls, NULL)) != 0) + errc(1, e, "pthread_create"); for (j = 0; j < 50; j++) pthread_join(cp[j], NULL); _exit(0); } if (pid == -1) err(1, "fork()"); wait(NULL); } return (0); } Index: user/pho/stress2/misc/mmap7.sh =================================================================== --- user/pho/stress2/misc/mmap7.sh (revision 285601) +++ user/pho/stress2/misc/mmap7.sh (revision 285602) @@ -1,152 +1,151 @@ #!/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$ # # Test scenario inspired by alc@ # Threaded version in order to "use the same pmap", as pointed out by kib@ # https://people.freebsd.org/~pho/stress/log/kostik601.txt # Fixed by r255396 . ../default.cfg dir=/tmp odir=`pwd` cd $dir sed '1,/^EOF/d' < $odir/$0 > $dir/wire_no_page.c -mycc -o mmap7 -Wall -Wextra wire_no_page.c -lpthread || exit 1 +mycc -o mmap7 -Wall -Wextra wire_no_page.c -lpthread || exit 1 rm -f wire_no_page.c cd $odir -cp /tmp/mmap7 /tmp/mmap7.inputfile (cd ../testcases/swap; ./swap -t 1m -i 2) & cp /tmp/mmap7 /tmp/mmap7.inputfile -/tmp/mmap7 /tmp/mmap7.inputfile +/tmp/mmap7 /tmp/mmap7.inputfile while ps | grep -v grep | grep -qw swap; do killall -9 swap 2>/dev/null sleep .1 done wait -rm -f /tmp/mmap7 /tmp/mmap7.inputfile +rm -f /tmp/mmap7 /tmp/mmap7.inputfile exit EOF #include #include #include #include #include #include #include #include #include #include #include #include char *p1, *p2, *p3; char c; const char *file; int fd; size_t len; struct stat st; void * test2(void *arg __unused) { int error, i; p1[arc4random() % len] = 1; p2[arc4random() % len] = 1; if (arc4random() % 100 < 30) i = p3[arc4random() % len]; if (arc4random() % 100 < 50) if ((error = mlock(p1, len)) == -1) err(1, "mlock"); if (arc4random() % 100 < 50) if ((error = msync(p1, len, MS_SYNC | MS_INVALIDATE)) == -1) if (errno != EBUSY) err(1, "msync"); return (0); } void test(void) { - int error, i; pthread_t cp[3]; + int e, error, i; if ((fd = open(file, O_RDWR)) == -1) err(1, "open %s", file); if ((error = fstat(fd, &st)) == -1) err(1, "stat(%s)", file); len = round_page(st.st_size); if ((p1 = mmap(NULL, len, PROT_READ | PROT_WRITE, MAP_SHARED, fd, 0)) == MAP_FAILED) err(1, "mmap"); if ((p2 = mmap(NULL, len, PROT_READ | PROT_WRITE, MAP_SHARED, fd, 0)) == MAP_FAILED) err(1, "mmap"); if ((p3 = mmap(NULL, len, PROT_READ , MAP_SHARED, fd, 0)) == MAP_FAILED) err(1, "mmap"); for (i = 0; i < 3; i++) - if (pthread_create(&cp[i], NULL, test2, NULL) != 0) - perror("pthread_create"); + if ((e = pthread_create(&cp[i], NULL, test2, NULL)) != 0) + errc(1, e, "pthread_create"); for (i = 0; i < 3; i++) pthread_join(cp[i], NULL); if (munmap(p3, len) == -1) err(1, "unmap()"); if (munmap(p2, len) == -1) err(1, "unmap()"); if (munmap(p1, len) == -1) err(1, "unmap()"); close(fd); _exit(0); } int main(int argc, char *argv[]) { int i; if (argc != 2) errx(1, "Usage: %s ", argv[0]); file = argv[1]; for (i = 0; i < 30000; i++) { if (fork() == 0) test(); wait(NULL); } return (0); } Index: user/pho/stress2/misc/msync.sh =================================================================== --- user/pho/stress2/misc/msync.sh (revision 285601) +++ user/pho/stress2/misc/msync.sh (revision 285602) @@ -1,203 +1,203 @@ #!/bin/sh # # Copyright (c) 2013 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$ # # msync(2) / mlockall(2) test scenario. # "panic: vm_fault_copy_wired: page missing" seen. # http://people.freebsd.org/~pho/stress/log/msync.txt # Fixed in r253189. [ `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/msync.c mycc -o msync -Wall -Wextra msync.c -lpthread || exit 1 rm -f msync.c cd $odir /tmp/msync killall msync > /dev/null 2>&1 rm -f /tmp/msync exit EOF #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include int syscallno = SYS_msync; #define N (128 * 1024 / (int)sizeof(u_int32_t)) u_int32_t r[N]; static void hand(int i __unused) { /* handler */ _exit(1); } unsigned long makearg(void) { unsigned int i; unsigned long val; val = arc4random(); i = arc4random() % 100; if (i < 20) val = val & 0xff; if (i >= 20 && i < 40) val = val & 0xffff; if (i >= 40 && i < 60) val = (unsigned long)(r) | (val & 0xffff); #if defined(__LP64__) if (i >= 60) { val = (val << 32) | arc4random(); if (i > 80) val = val & 0x00007fffffffffffUL; } #endif return(val); } void * calls(void *arg __unused) { int i, num; unsigned long arg1, arg2, arg3; usleep(1000); num = syscallno; for (i = 0; i < 500; i++) { arg1 = makearg(); arg2 = makearg(); #if 0 arg3 = makearg(); arg3 = arg3 & ~MS_INVALIDATE; /* No problem seen */ #else arg3 = MS_INVALIDATE; /* panic */ #endif #if 0 fprintf(stderr, "%2d : syscall(%3d, 0x%lx, 0x%lx, 0x%lx)\n", i, num, arg1, arg2, arg3); usleep(50000); #endif alarm(1); syscall(num, arg1, arg2, arg3); num = 0; } return (0); } void wd(void) { int i; if (mlockall(MCL_CURRENT | MCL_FUTURE) != 0) err(1, "mlockall failed"); for (i = 0; i < 800; i++) { if (fork() == 0) { usleep(20000); _exit(0); } wait(NULL); usleep(100000); } _exit(0); } int main(void) { struct passwd *pw; pthread_t cp[50]; - int i, j; + int e, i, j; if (fork() == 0) wd(); if ((pw = getpwnam("nobody")) == NULL) err(1, "no such user: nobody"); if (setgroups(1, &pw->pw_gid) || setegid(pw->pw_gid) || setgid(pw->pw_gid) || seteuid(pw->pw_uid) || setuid(pw->pw_uid)) err(1, "Can't drop privileges to \"nobody\""); endpwent(); signal(SIGALRM, hand); signal(SIGILL, hand); signal(SIGFPE, hand); signal(SIGSEGV, hand); signal(SIGBUS, hand); signal(SIGURG, hand); signal(SIGSYS, hand); signal(SIGTRAP, hand); alarm(180); for (i = 0; i < 8000; i++) { if (fork() == 0) { arc4random_stir(); for (j = 0; j < N; j++) r[j] = arc4random(); for (j = 0; j < 50; j++) - if (pthread_create(&cp[j], NULL, calls, NULL) != 0) - perror("pthread_create"); + if ((e = pthread_create(&cp[j], NULL, calls, NULL)) != 0) + errc(1, e, "pthread_create"); for (j = 0; j < 50; j++) pthread_join(cp[j], NULL); _exit(0); } wait(NULL); } return (0); } Index: user/pho/stress2/misc/sigreturn.sh =================================================================== --- user/pho/stress2/misc/sigreturn.sh (revision 285601) +++ user/pho/stress2/misc/sigreturn.sh (revision 285602) @@ -1,118 +1,119 @@ #!/bin/sh # # Copyright (c) 2013 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: smp_tlb_shootdown: interrupts disabled" seen. # http://people.freebsd.org/~pho/stress/log/freebsd4_sigreturn.txt # Fixed in r251033. . ../default.cfg dir=/tmp odir=`pwd` cd $dir sed '1,/^EOF/d' < $odir/$0 > $dir/sigreturn.c mycc -o sigreturn -Wall -Wextra sigreturn.c -lpthread || exit 1 rm -f sigreturn.c cd $odir /tmp/sigreturn rm -f /tmp/sigreturn ./sigreturn.core exit EOF #include #include #include #include #include #include #include #include #include #include #include unsigned long buf[] = { 0xe8243489, 0x000e7cc9, 0x85204e8b, 0xc0940fc9, 0x0fc2950f, 0x5589d2b6, 0x56bf0fe4, 0xe855890e, 0x890fd285, 0x0000014a, 0x850fc084, 0x00000142, 0x891c468b, 0xd1ff2404, 0x00012ee9, 0x04b3e800, 0x388bffff, 0xe8243489, 0xfffefbd9, 0xff04a4e8, 0xe93889ff, 0x00000343, 0x0fc08566, 0x00031f84, 0x46bf0f00, 0x2404890e, 0x042444c7, 0x00000003, 0xfefb90e8, 0x85c789ff, 0x0d880fff, 0x89000002, 0x03e083f8, 0x7402f883, 0xf04d8b0e, 0x3903e183, 0xe1850fc8, 0xf6000002, 0x74080c46, 0x24348908, 0x0e7c2ce8, 0xf0458b00, 0xf931c189, 0x7408c1f6, 0xf7e7832b, 0x0908e083, 0x4ebf0ff8, 0x2444890e, 0x240c8908, 0x042444c7, 0x00000004, 0xfefb34e8, 0x0fc085ff, 0x0001b388, 0xf0458b00, 0x7404c4f6, 0x46bf0f1f, 0x2404890e, 0x082444c7, 0x00000000, 0x042444c7, 0x00000000, 0xff0898e8, 0xf0458bff, 0x237508a8, 0xc7243489, 0x000c2444, 0xc7000000, 0x00082444, 0xc7000000, 0x00042444, 0xe8000000, 0x000e86ad, 0xa9f0458b, 0x00100000, 0xbf0f1c74, 0x04890e46, 0x2444c724, 0x00000108, 0x2444c700, 0x00000204, 0xfabbe800, 0xbf0ffffe, 0x45c70e7e, 0xffffffe8, 0xe445c7ff, 0x00000000, 0xc76634eb, 0x00200c46, 0xffe845c7 }; static void hand(int i __unused) { /* handler */ _exit(1); } void * calls(void *arg __unused) { alarm(1); syscall(SYS_freebsd4_sigreturn, buf); return (0); } int main(void) { pthread_t cp; + int e; signal(SIGALRM, hand); signal(SIGILL, hand); signal(SIGFPE, hand); signal(SIGSEGV, hand); signal(SIGBUS, hand); signal(SIGURG, hand); signal(SIGSYS, hand); signal(SIGTRAP, hand); if (fork() == 0) { - if (pthread_create(&cp, NULL, calls, NULL) != 0) - perror("pthread_create"); + if ((e = pthread_create(&cp, NULL, calls, NULL)) != 0) + errc(1, e, "pthread_create"); pthread_join(cp, NULL); _exit(0); } wait(NULL); return (0); } Index: user/pho/stress2/misc/sndstat.sh =================================================================== --- user/pho/stress2/misc/sndstat.sh (revision 285601) +++ user/pho/stress2/misc/sndstat.sh (revision 285602) @@ -1,141 +1,141 @@ #!/bin/sh # # Copyright (c) 2012 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$ # # Test of access to /dev/sndstat # Permanent "/dev/sndstat: Device busy" seen. # "panic: sbuf_put_byte called with finished or corrupt sbuf" seen. # Fixed in r234932 . ../default.cfg [ -r /dev/sndstat ] || exit 1 here=`pwd` cd /tmp sed '1,/^EOF/d' < $here/$0 > sndstat.c mycc -o sndstat -Wall -Wextra sndstat.c -lpthread rm -f sndstat.c /tmp/sndstat > /dev/null rm -f /tmp/sndstat exit 0 EOF #include #include #include #include #include #include #include #include #include #include #include #include int fd; char path[] = "/dev/sndstat"; void * test1(void *arg __unused) { int sfd, i, n; char buf[512]; n = 0; for (i = 0; i < 5; i++) { if ((sfd = open(path, O_RDONLY)) == -1) continue; read(sfd, buf, sizeof(buf)); fprintf(stdout, "%s\n", buf); n++; close(sfd); } if (n == 0) { if ((sfd = open(path, O_RDONLY)) == -1) warn("FAIL open(%s)", path); if (sfd > 0) close(sfd); } return (0); } void * test2(void *arg __unused) { char buf[512]; bzero(buf, sizeof(buf)); if (read(fd, buf, sizeof(buf)) != -1) fprintf(stdout, "%s\n", buf); else warn("read()"); return (0); } int main(void) { pthread_t rp[10]; - int i, j; + int e, i, j; /* Parallel open test */ for (i = 0; i < 10; i++) { - if (pthread_create(&rp[i], NULL, test1, NULL) != 0) - perror("pthread_create"); + if ((e = pthread_create(&rp[i], NULL, test1, NULL)) != 0) + errc(1, e, "pthread_create"); } for (i = 0; i < 10; i++) pthread_join(rp[i], NULL); /* Parallel read test */ for (i = 0; i < 10; i++) { if ((fd = open(path, O_RDONLY)) == -1) { warn("open()"); continue; } for (j = 0; j < 4; j++) - if (pthread_create(&rp[j], NULL, test2, NULL) != 0) - perror("pthread_create"); + if ((e = pthread_create(&rp[j], NULL, test2, NULL)) != 0) + errc(1, e, "pthread_create"); for (j = 0; j < 4; j++) pthread_join(rp[j], NULL); close(fd); } return (0); } Index: user/pho/stress2/misc/umountf7.sh =================================================================== --- user/pho/stress2/misc/umountf7.sh (revision 285601) +++ user/pho/stress2/misc/umountf7.sh (revision 285602) @@ -1,168 +1,170 @@ #!/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$ # # "panic: handle_written_inodeblock: live inodedep 0xcc731200" seen. # http://people.freebsd.org/~pho/stress/log/umountf7.txt +# https://people.freebsd.org/~pho/stress/log/kostik824.txt # Problem only seen with SU+J. [ `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/umountf7.c mycc -o umountf7 -Wall -Wextra umountf7.c -lpthread || exit 1 rm -f umountf7.c cd $odir mount | grep "on $mntpoint " | grep -q /dev/md && umount -f $mntpoint mdconfig -l | grep -q md$mdstart && mdconfig -d -u $mdstart mdconfig -a -t swap -s 3g -u $mdstart || exit 1 bsdlabel -w md$mdstart auto -newfs -j md${mdstart}$part > /dev/null +[ "$newfs_flags" = "-U" ] && opt="-j" +newfs $opt md${mdstart}$part > /dev/null mount /dev/md${mdstart}$part $mntpoint daemon sh -c '(cd ../testcases/swap; ./swap -t 2m -i 4)' parallel=4 for j in `jot $parallel`; do [ -d $mntpoint/$j ] || mkdir $mntpoint/$j done for j in `jot $parallel`; do (cd $mntpoint/$j; /tmp/umountf7 100000) & done sleep 30 umount -f $mntpoint pkill umountf7 wait while pkill -9 swap; do : done find $mntpoint -type f while mount | grep "on $mntpoint " | grep -q /dev/md; do umount $mntpoint || sleep 1 done mdconfig -d -u $mdstart rm -f /tmp/umountf7 exit EOF #include #include #include #include #include #include pid_t pid; volatile int n, n2; int mx; void * cr(void *arg __unused) { char file[80]; int fd, i; for (i = 0; i < mx; i++) { snprintf(file, sizeof(file), "f%06d.%06d", pid, i); if ((fd = open(file, O_RDWR | O_CREAT | O_TRUNC, 0600)) < 0) err(1, "open(%s)", file); close(fd); n++; } return (0); } void * mv(void *arg __unused) { char from[80], to[80]; int i; for (i = 0; i < mx; i++) { while (n == -1 || i > n) pthread_yield(); snprintf(from, sizeof(from), "f%06d.%06d", pid, i); snprintf(to , sizeof(to ), "g%06d.%06d", pid, i); if (rename(from, to) == -1) warn("rename(%s, %s)", from, to); n2++; } return (0); } void * rm(void *arg __unused) { char file[80]; int i; for (i = 0; i < mx; i++) { while (n2 == -1 || i > n2) pthread_yield(); snprintf(file, sizeof(file), "g%06d.%06d", pid, i); if (unlink(file) == -1) warn("unlink(%s)", file); } return (0); } int main(int argc, char **argv) { pthread_t rp[3]; - int i; + int e, i; if (argc != 2) errx(1, "Usage: %s ", argv[0]); mx = atoi(argv[1]); n = n2 = -1; pid = getpid(); - if (pthread_create(&rp[0], NULL, cr, NULL) != 0) - err(1, "pthread_create"); + if ((e = pthread_create(&rp[0], NULL, cr, NULL)) != 0) + errc(1, e, "pthread_create"); usleep(arc4random() % 1000); - if (pthread_create(&rp[1], NULL, mv, NULL) != 0) - err(1, "pthread_mv"); + if ((e = pthread_create(&rp[1], NULL, mv, NULL)) != 0) + errc(1, e, "pthread_mv"); usleep(arc4random() % 1000); - if (pthread_create(&rp[2], NULL, rm, NULL) != 0) - perror("pthread_rm"); + if ((e = pthread_create(&rp[2], NULL, rm, NULL)) != 0) + errc(1, e, "pthread_rm"); for (i = 0; i < 3; i++) pthread_join(rp[i], NULL); return (0); }