4 # Copyright (c) 2014 EMC Corp.
7 # Redistribution and use in source and binary forms, with or without
8 # modification, are permitted provided that the following conditions
10 # 1. Redistributions of source code must retain the above copyright
11 # notice, this list of conditions and the following disclaimer.
12 # 2. Redistributions in binary form must reproduce the above copyright
13 # notice, this list of conditions and the following disclaimer in the
14 # documentation and/or other materials provided with the distribution.
16 # THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
17 # ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
18 # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
19 # ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
20 # FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
21 # DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
22 # OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
23 # HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
24 # LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
25 # OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
29 # Test multiple (parallel) core dumps and mount / umount.
30 # mount(8) stuck in "ufs" or "tmpfs".
31 # http://people.freebsd.org/~pho/stress/log/kostik724.txt
33 # On i386 pgrep(1) loops. Fixed by r272566.
35 # "Sleeping on "pmapdi" with the following non-sleepable locks held:"
36 # https://people.freebsd.org/~pho/stress/log/kostik883.txt
38 [ `id -u ` -ne 0 ] && echo "Must be root!" && exit 1
44 sed '1,/^EOF/d' < $odir/$0 > core3.c
45 mycc -o core3 -Wall -Wextra -O2 core3.c || exit 1
49 mount | grep -q "on $mntpoint " && umount $mntpoint
50 [ -c /dev/md$mdstart ] && mdconfig -d -u $mdstart
51 mdconfig -a -t swap -s 1g -u $mdstart
52 bsdlabel -w md$mdstart auto
53 newfs $newfs_flags md${mdstart}$part > /dev/null
54 mount /dev/md${mdstart}$part $mntpoint
58 su $testuser -c "/tmp/core3 $mntpoint/d" &
62 while pgrep -q core3; do
65 done > /dev/null 2>&1 &
66 while pgrep -q core3; do
68 mount /dev/md${mdstart}$part $mntpoint
72 mount | grep -q "on $mntpoint " &&
74 mdconfig -d -u $mdstart
75 [ $status -ne 0 ] && exit $status
78 mount -o size=1g -t tmpfs tmpfs $mntpoint
79 su $testuser -c "/tmp/core3 $mntpoint/d" &
83 while pgrep -q core3; do
87 while pgrep -q core3; do
88 if [ ! -d $mntpoint/d ]; then
89 mount -t tmpfs tmpfs $mntpoint
96 mount | grep -q "on $mntpoint " || break
103 #include <sys/mman.h>
104 #include <sys/wait.h>
115 #define SIZ (4 * 1024 * 1024)
121 hand(int i __unused) { /* handler */
131 p = mmap(NULL, len, PROT_READ | PROT_WRITE, MAP_ANON, -1, 0);
134 * This loop caused mount to wait in "ufs".
135 * Adding a usleep(200) would remove the hang.
137 signal(SIGALRM, hand);
139 while (chdir(argv[1]) == -1)
148 main(int argc, char *argv[])
154 errx(1, "Usage: %s <path>", argv[0]);
158 while (time(NULL) - start < 600 && status == 0) {
159 for (i = 0; i < PARALLEL; i++) {
163 for (i = 0; i < PARALLEL; i++) {
165 if (WEXITSTATUS(s) == TIMEDOUT)