public inbox for cygwin@cygwin.com
 help / color / mirror / Atom feed
From: Corinna Vinschen <corinna-cygwin@cygwin.com>
To: cygwin@cygwin.com
Subject: Re: mmap failing with MAP_FIXED
Date: Mon, 4 Jul 2022 10:19:43 +0200	[thread overview]
Message-ID: <YsKin3kIuaUsmJXE@calimero.vinschen.de> (raw)
In-Reply-To: <000001d88d68$4d5a7a40$e80f6ec0$@cl.cam.ac.uk>

On Jul  1 17:33, David Allsopp wrote:
> This program fails at the second mmap call with EINVAL:
> 
>   #include <stdio.h>
>   #include <sys/mman.h>
>   #include <error.h>
> 
>   int main (void) {
>     void * mem;
>     /* Reserve 256MB address space for the minor heaps */
>     mem = mmap(0, 268439552, PROT_NONE, MAP_PRIVATE | MAP_ANONYMOUS, -1, 0);
>     if (mem == MAP_FAILED)
>       error(1, 0, "Reservation failed");
>     /* Commit the first 2MB heap */
>     if (mmap(mem, 2097152, PROT_READ | PROT_WRITE, MAP_PRIVATE |
> MAP_ANONYMOUS | MAP_FIXED, -1, 0) == MAP_FAILED)
>       error(1, 0, "Commit failed");
>   }
> 
> Is this something that's expected to fail for Cygwin, or a bug?

Depends on the point of view, I guess.  PROT_NONE pages are not just
reserved pages in the Windows sense.  mmap'ed pages are always commited
and PROT_NONE is just a page protection.  Using mmap to change the page
protection of already commited memory is not implemented.  To change
this, use mprotect.


Corinna

      parent reply	other threads:[~2022-07-04  8:19 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-07-01 16:33 David Allsopp
2022-07-01 16:45 ` gs-cygwin.com
2022-07-04  8:19 ` Corinna Vinschen [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=YsKin3kIuaUsmJXE@calimero.vinschen.de \
    --to=corinna-cygwin@cygwin.com \
    --cc=cygwin@cygwin.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).