Date: Sat, 27 Feb 1999 11:59:28 -0800 (PST) From: Jonathan Hanna <pangolin@home.com> To: current@freebsd.org Subject: lockmgr panic with mmap() Message-ID: <19990227195928.SCCF11952.mail.rdc1.bc.wave.home.com@cr1003333-a.crdva1.bc.wave.home.com>
next in thread | raw e-mail | index | archive | help
[-- Attachment #1 --]
The attached program sometimes causes a lockmgr panic. I do not think is always
did. I am running 4.0-CURRENT form Feb 19.
The trace is:
panic lockmgr: locking against self
lockmgr
mv_map_growstack
grow_stack
trap_pfault
trap
calltrap
subyte
syscall
...
A command on a running image such as this usually does it, though I do not know what
conditions are neccessary:
fincore /usr/local/netscape-4.5/communicator-4.5.bin
Jonathan Hanna <pangolin@home.com>
[-- Attachment #2 --]
#include <stdio.h>
#include <unistd.h>
#include <stdlib.h>
#include <sys/types.h>
#include <sys/mman.h>
#include <fcntl.h>
#include <sys/stat.h>
#include <machine/param.h>
/*
** print pages of file in core
*/
void usage(char *name)
{
printf("Usage: %s [-ns] files...\n",name);
printf("\t-n\t\tDo not print filename\n");
printf("\t-o\t\tOnly print files with at least one page in core\n");
printf("\t-s\t\tDo not print file size in pages\n");
}
main(int ac,char **av)
{
int c;
int print_name = 1;
int print_sizepages = 1;
int only_nonzero = 0;
int status = 0;
while((c = getopt(ac,av,"nos")) != -1) {
switch(c) {
case 'n':
print_name = 0;
break;
case 'o':
only_nonzero = 1;
break;
case 's':
print_sizepages = 0;
break;
default:
usage(av[0]);
exit(1);
}
}
for(; optind < ac ; optind++) {
int fd;
int pind,pcount;
caddr_t addr;
struct stat statbuf;
size_t len;
size_t numpages;
char *pvec;
if ((fd = open(av[optind],O_RDONLY)) < 0) {
perror(av[optind]);
status = 1;
continue;
}
if (fstat(fd,&statbuf)) {
perror("fstat");
close(fd);
status = 1;
continue;
}
len = statbuf.st_size;
numpages = len/PAGE_SIZE + ((len % PAGE_SIZE) != 0);
if (! (statbuf.st_mode & (S_IFREG|S_IFCHR))) {
pcount = 0;
} else if (len) {
if ((addr = mmap(0,len,PROT_READ,MAP_SHARED,fd,0)) == MAP_FAILED) {
perror("mmap");
exit(1);
}
pvec = malloc(numpages);
if (mincore(addr,len,pvec))
{
perror("mincore");
exit(1);
}
for(pcount = 0,pind = 0 ; pind < numpages ; pind++) {
if (pvec[pind]) pcount++;
}
free(pvec);
if (munmap(addr,len)) {
perror("munmap");
exit(1);
}
} else {
pcount = 0;
}
if (pcount || !only_nonzero) {
if (print_name) printf("%s: ",av[optind]);
printf("%d",pcount);
if (print_sizepages) printf("/%d",numpages);
printf("\n");
}
close(fd);
}
exit(status);
}
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?19990227195928.SCCF11952.mail.rdc1.bc.wave.home.com>
