1#!/bin/sh 2 3# Test scenario by: David Cross <dcrosstech@gmail.com> 4 5# "panic: softdep_deallocate_dependencies: dangling deps" seen. 6# https://people.freebsd.org/~pho/stress/log/mmap29.txt 7# Fixed by: r302567. 8 9. ../default.cfg 10[ `id -u ` -ne 0 ] && echo "Must be root!" && exit 1 11 12[ -z "`which timeout`" ] && exit 0 13mount | grep "on $mntpoint " | grep -q /dev/md && umount -f $mntpoint 14mdconfig -l | grep -q md$mdstart && mdconfig -d -u $mdstart 15mdconfig -a -t swap -s 2g -u $mdstart || exit 1 16bsdlabel -w md$mdstart auto 17newfs -U md${mdstart}$part > /dev/null 18mount /dev/md${mdstart}$part $mntpoint 19 20mkdir $mntpoint/mmap29 21cd /tmp 22cat > mmap29.c <<EOFHERE 23#include <sys/param.h> 24#include <sys/mman.h> 25#include <sys/stat.h> 26 27#include <err.h> 28#include <fcntl.h> 29#include <stdio.h> 30#include <stdlib.h> 31#include <unistd.h> 32 33int 34main(int argc, char **argv) 35{ 36 int fd; 37 unsigned char *memrange; 38 39 if (argc != 2) { 40 fprintf(stderr, "Usage: %s <file>\n", argv[0]); 41 exit(1); 42 } 43 unlink(argv[1]); 44 if ((fd = open(argv[1], O_RDWR | O_CREAT, DEFFILEMODE)) == -1) 45 err(1, "open(%s)", argv[1]); 46 lseek(fd, 0xbfff, SEEK_SET); 47 write(fd, "\0", 1); 48 if ((memrange = mmap(0, 0x2b6000, PROT_READ | PROT_WRITE, MAP_SHARED | 49 MAP_HASSEMAPHORE | MAP_NOSYNC, fd, 0)) == MAP_FAILED) 50 err(1, "mmap"); 51 memrange[0] = 5; 52 munmap(memrange, 0x2b6000); 53 close(fd); 54 55 return (0); 56} 57EOFHERE 58 59cc -o mmap29 -Wall -Wextra -O0 -g mmap29.c || exit 1 60rm mmap29.c 61./mmap29 $mntpoint/mmap29/mmap291 62old=`sysctl -n kern.maxvnodes` 63trap "sysctl kern.maxvnodes=$old" EXIT INT 64sysctl kern.maxvnodes=2000 65timeout 60 find / -xdev -print >/dev/null 66while mount | grep "on $mntpoint " | grep -q /dev/md; do 67 umount $mntpoint || sleep 1 68done 69mdconfig -d -u $mdstart 70rm mmap29 71exit 0 72