Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 11 Aug 1999 10:30:34 -0700
From:      David Greenman <dg@root.com>
To:        Oleg Derevenetz <oleg@oleg.sani-c.vrn.ru>
Cc:        freebsd-hackers@FreeBSD.ORG
Subject:   Re: mmap bug 
Message-ID:  <199908111730.KAA26611@implode.root.com>
In-Reply-To: Your message of "Wed, 11 Aug 1999 20:48:08 %2B0400." <199908111648.UAA01527@oleg.sani-c.vrn.ru> 

next in thread | previous in thread | raw e-mail | index | archive | help
   This report seems to be severely lacking in details. First, I don't
understand why it is called "mmap" since it doesn't do an mmap and the
"addr" that is being frobbed with isn't even initialized. Second, I
get a core dump when I run it on a -stable machine:

[speedy:tmp9] mmap
unlink files? NO
mmaping 10485760 byte region on file 0
Segmentation fault (core dumped)

   ...which is exactly what I'd expect when dealing with a bogus pointer.
You didn't specify what version of FreeBSD you saw a hang and didn't provide
any details of the hang. Please provide more information so that we can
help you. Thanks.

-DG

David Greenman
Co-founder/Principal Architect, The FreeBSD Project - http://www.freebsd.org
Creator of high-performance Internet servers - http://www.terasolutions.com

>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.
>
>#include <stdio.h>
>#include <stdlib.h>
>#include <sys/types.h>
>#include <sys/mman.h>
>#include <unistd.h>
>#include <fcntl.h>
>#include <errno.h>
>  
>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


To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-hackers" in the body of the message




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?199908111730.KAA26611>