Subject: RE: problems with mmap/munmap - HELP
From: [email-masked] (Gary Fuehrer)

18 Sep 1997 13:55:17 -0700
Message-ID: <6CC63E2E4FC1D011A2A700609716117A266F37.cygnus.gnu-win32@seawolf>
Mime-Version: 1.0
Content-Type: text/plain
To: [email-masked], "'Daniel Diaz'" <[email-masked]>

Partial munmapping is not implemented in CygWin32.  It is also not
required for POSIX.1.  If you're willing to explicitly request the
addresses of stack space regions, then you could simply leave gaps in
your mmap requests.  If you aren't willing to specify the address, I
can't think of any technique that doesn't depend on the specifics of the
mmap implementation and/or luck.

By the way, b18 has a bug in the implementation of mmap() an fork() for
regions mapped with MAP_PRIVATE.  I have submitted a fix, but I haven't
heard if anyone has incorporated it anywhere yet.  Don't know if this
matters to you.

Good luck,
Gary

> ----------
> From: 	Daniel Diaz[SMTP:[email-masked]]
> Sent: 	Thursday, September 18, 1997 3:31 AM
> To: 	[email-masked]
> Subject: 	problems with mmap/munmap - HELP
> 
> Hi,
> I'm a new user of gnu-win32-gcc, btw congratulations to all people
> working on 
> this project.
> 
> I'd like to port a compiler initially written for the unix world. A
> key 
> feature of my system is that it uses the MMU to avoid to chech stacks 
> overflows.
> Indeed, i use 3 stacks and to avoid to check for overflows i use the 
> mmap/munmap facility. More precisely I allocate a 'big' space with
> mmap 
> (MAP_ANONYMOUS) whose size  equals to the sum of the size of each
> stack + 3 
> pages (obtained by getpagesize()), then I munmap the page which
> follows each 
> stack. Here is the memory map obtained:
> 
>        +-----------------+
>        |  a free page    | <- page given back by munmap
>        +-----------------+
>        |    space for    |
>        |      stack      |
>        |       # 3       |
>        |        :        |
>        +-----------------+
>        |  a free page    | <- page given back by munmap
>        +-----------------+
>        |    space for    |
>        |      stack      |
>        |       # 2       |
>        |        :        |
>        +-----------------+
>        |  a free page    | <- page given back by munmap
>        +-----------------+
>        |    space for    |
>        |      stack      |
>        |       # 1       |
>        |        :        |
>        +-----------------+ <- address given by mmap
> 
> When a stack overflows, an attempt to read/write into the munmapped
> page 
> occurs, the MMU triggers than a signal (SIGSEGV) that i catch to
> inform the
> user about the overflow.
> 
> The problem under gnu-win32-gcc is that i cannot munmap at an address 
> different from the one returned by mmap (so i can only give back the
> first 
> page, ie. inside the space for the first stack).
> 
> How could I do ? Where are the docs about mmap ? I have also seen a
> function 
> mprotect(), could I use it ?
> 
> Since this mechanism is very important in my implementation I'd really
> likle 
> to find an efficient solution.
> 
> Please Help :-)
> 
> 
> 
> 
> -- 
> Daniel Diaz
> INRIA Rocquencourt - 78153 Le Chesnay Cedex
> FRANCE               tel: +33 1 39 63 52 67
>                 email: [email-masked]
> ============================================
> 
> 
> -
> For help on using this list (especially unsubscribing), send a message
> to
> "[email-masked]" with one line of text: "help".
> 
-
For help on using this list (especially unsubscribing), send a message to
"[email-masked]" with one line of text: "help".