Date: Fri, 3 Sep 1999 17:05:49 -0700 (PDT) From: ivan@desktop.com To: freebsd-gnats-submit@freebsd.org Subject: kern/13563: mmap() too much ==> hang system Message-ID: <19990904000549.3BD9814BFA@hub.freebsd.org>
index | next in thread | raw e-mail
>Number: 13563
>Category: kern
>Synopsis: mmap() too much ==> hang system
>Confidential: no
>Severity: serious
>Priority: medium
>Responsible: freebsd-bugs
>State: open
>Quarter:
>Keywords:
>Date-Required:
>Class: sw-bug
>Submitter-Id: current-users
>Arrival-Date: Fri Sep 3 17:10:01 PDT 1999
>Closed-Date:
>Last-Modified:
>Originator: Ivan Pulleyn
>Release: 3.0-RELEASE, 3.2-RELEASE
>Organization:
DESKTOP.COM
>Environment:
FreeBSD b0.jumpdata.com 3.2-RELEASE FreeBSD 3.2-RELEASE #0: Mon Aug 23 17:16:56 PDT 1999 buser@b0.jumpdata.com:/usr/src/sys/compile/B1 i386
>Description:
Writing to a mmap() region that is larger than the amount of physical
RAM in the machine causes a hang. System no longer responds and a
reboot is needed to restore the system.
>How-To-Repeat:
Compile the following program. Run it with a mmap() size that is
larger than the amount of physucal RAM in the machine.
#include <unistd.h>
#include <stdio.h>
#include <stdlib.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <sys/mman.h>
int main(int argc, char * argv[])
{
int fd = -1, x = 0;
char * map = NULL;
off_t size = 0;
if (argc < 3)
{
fprintf(stderr, "Usage: %s file size_in_megabytes\n", argv[0]);
return -1;
}
if ((fd = open(argv[1], O_CREAT|O_RDWR, 0664)) == -1)
{
fprintf(stderr, "Could not open %s\n", argv[1]);
return -1;
}
size = atoi(argv[2]);
size = size * 1024 * 1024;
if (lseek(fd, size, SEEK_SET) != size)
{
fprintf(stderr, "Could not seek\n");
return -1;
}
write(fd, &size, 1);
if ((map = mmap(0, size, PROT_READ|PROT_WRITE, MAP_SHARED, fd, 0)) == NULL)
{
fprintf(stderr, "Could not mmap\n");
return -1;
}
fprintf(stdout, "Writing:");
for (x=0; x<size; x++)
{
map[x] = 1;
if ((x % (1024*1024)) == 0)
{
fprintf(stdout, ".");
fflush(stdout);
}
}
fprintf(stdout, "done\n");
munmap(map, size);
return 0;
}
>Fix:
>Release-Note:
>Audit-Trail:
>Unformatted:
To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-bugs" in the body of the message
home |
help
Want to link to this message? Use this
URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?19990904000549.3BD9814BFA>
