| www.delorie.com/archives/browse.cgi | search |
| X-Recipient: | archive-cygwin AT delorie DOT com |
| X-Original-To: | cygwin AT cygwin DOT com |
| Delivered-To: | cygwin AT cygwin DOT com |
| DMARC-Filter: | OpenDMARC Filter v1.4.1 sourceware.org 375E63858D28 |
| Authentication-Results: | sourceware.org; |
| dmarc=none (p=none dis=none) header.from=gluelogic.com | |
| Authentication-Results: | sourceware.org; spf=pass smtp.mailfrom=gluelogic.com |
| X-Spam-Checker-Version: | SpamAssassin 3.4.6 (2021-04-09) on |
| server2.sourceware.org | |
| X-Spam-Language: | en |
| X-Spam-Relay-Country: | |
| X-Spam-DCC: | B=; R=smtp1.atof.net 1202; Body=1 Fuz1=1 Fuz2=1 |
| X-Spam-RBL: | |
| X-Spam-PYZOR: | Reported 0 times. |
| Date: | Fri, 1 Jul 2022 12:45:31 -0400 |
| From: | gs-cygwin DOT com AT gluelogic DOT com |
| To: | David Allsopp <David DOT Allsopp AT cl DOT cam DOT ac DOT uk> |
| Subject: | Re: mmap failing with MAP_FIXED |
| Message-ID: | <Yr8kqyUZXlFToSn8@xps13> |
| References: | <000001d88d68$4d5a7a40$e80f6ec0$@cl.cam.ac.uk> |
| Mime-Version: | 1.0 |
| In-Reply-To: | <000001d88d68$4d5a7a40$e80f6ec0$@cl.cam.ac.uk> |
| X-Spam-Status: | No, score=-2.2 required=5.0 tests=BAYES_00, KAM_DMARC_STATUS, |
| SPF_HELO_NONE, SPF_PASS, TXREP, | |
| T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 | |
| X-BeenThere: | cygwin AT cygwin DOT com |
| X-Mailman-Version: | 2.1.29 |
| List-Id: | General Cygwin discussions and problem reports <cygwin.cygwin.com> |
| List-Unsubscribe: | <https://cygwin.com/mailman/options/cygwin>, |
| <mailto:cygwin-request AT cygwin DOT com?subject=unsubscribe> | |
| List-Archive: | <https://cygwin.com/pipermail/cygwin/> |
| List-Post: | <mailto:cygwin AT cygwin DOT com> |
| List-Help: | <mailto:cygwin-request AT cygwin DOT com?subject=help> |
| List-Subscribe: | <https://cygwin.com/mailman/listinfo/cygwin>, |
| <mailto:cygwin-request AT cygwin DOT com?subject=subscribe> | |
| Cc: | cygwin AT cygwin DOT com |
| Errors-To: | cygwin-bounces+archive-cygwin=delorie DOT com AT cygwin DOT com |
| Sender: | "Cygwin" <cygwin-bounces+archive-cygwin=delorie DOT com AT cygwin DOT com> |
On Fri, Jul 01, 2022 at 05:33:31PM +0100, 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? The example
> is extracted from OCaml 5.0's runtime, which reserves an area of address
> space and then commits chunks of it as required. The above snippet comes
> from the Linux side, on Windows we're using VirtualAlloc with PAGE_NOACCESS
> to reserve the address space and then VirtualAlloc with MEM_COMMIT and
> PAGE_READWRITE to commit smaller portions of it.
>
> Is there a way to do that with Cygwin's mmap?
Have you tried 'msync()' with MS_ASYNC flag as an alternative approach?
Cheers, Glenn
--
Problem reports: https://cygwin.com/problems.html
FAQ: https://cygwin.com/faq/
Documentation: https://cygwin.com/docs.html
Unsubscribe info: https://cygwin.com/ml/#unsubscribe-simple
| webmaster | delorie software privacy |
| Copyright © 2019 by DJ Delorie | Updated Jul 2019 |