From owner-freebsd-hackers Wed Aug 11 10: 7:16 1999 Delivered-To: freebsd-hackers@freebsd.org Received: from lestat.nas.nasa.gov (lestat.nas.nasa.gov [129.99.33.127]) by hub.freebsd.org (Postfix) with ESMTP id 3F85915571 for ; Wed, 11 Aug 1999 10:07:13 -0700 (PDT) (envelope-from thorpej@lestat.nas.nasa.gov) Received: from lestat (localhost [127.0.0.1]) by lestat.nas.nasa.gov (8.8.8/8.6.12) with ESMTP id KAA26592; Wed, 11 Aug 1999 10:04:28 -0700 (PDT) Message-Id: <199908111704.KAA26592@lestat.nas.nasa.gov> To: Oleg Derevenetz Cc: freebsd-hackers@FreeBSD.ORG Subject: Re: mmap bug Reply-To: Jason Thorpe From: Jason Thorpe Date: Wed, 11 Aug 1999 10:04:26 -0700 Sender: owner-freebsd-hackers@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.ORG On Wed, 11 Aug 1999 20:48:08 +0400 (MSD) Oleg Derevenetz wrote: > This small program, running as 'mmap', not 'mmap -u', can hang my machine. > Is this a known bug in FreeBSD's kernel, or it is my fantasy ? > Thank you for answer. If it hangs your system, must be a bug in FreeBSD. Here is what happens on a NetBSD/alpha system: bishop:thorpej 26$ ./mmap-bug unlink files? NO mmaping 10485760 byte region on file 0 Memory fault (core dumped) bishop:thorpej 27$ ./mmap-bug -u unlink files? YES mmaping 10485760 byte region on file 0 Memory fault (core dumped) bishop:thorpej 28$ ...which is correct. There isn't any backing store for the region you've mapped. > > #include > #include > #include > #include > #include > #include > #include > > main(int argc, char *argv[]) > { > int fd; > int i; > int len=1024*1024*10; /*ie 10Mbytes*/ > caddr_t addr; > char ttt[80]; > int bunlink = 0; > > if ( argc > 1 && strcmp(argv[1], "-u") == 0 ) { > bunlink = 1; > } > printf("unlink files? %s\n", bunlink ? "YES" : "NO"); > > for (i=0;;i++) > { > sprintf (ttt,"%d",i); > printf("mmaping %ld byte region on file %s\n", len, ttt); > fd=open(ttt,O_CREAT|O_RDWR,0666); > if (fd<0) > { > printf("mmap error %ld",errno); > exit(1); > } > memset(addr,'x',len); > if ( munmap(addr, len) != 0 ) { > fprintf(stderr, "munmap failed\n"); > exit(EXIT_FAILURE); > } > close(fd); > if ( bunlink ) unlink(ttt); > } > } > > > To Unsubscribe: send mail to majordomo@FreeBSD.org > with "unsubscribe freebsd-hackers" in the body of the message -- Jason R. Thorpe To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-hackers" in the body of the message