www.delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2022/07/01/12:33:29

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 55171385AC3B
Authentication-Results: sourceware.org;
dmarc=fail (p=none dis=none) header.from=cl.cam.ac.uk
Authentication-Results: sourceware.org;
spf=pass smtp.mailfrom=return.smtpservice.net
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed;
d=smtpservice.net; s=md6hz0.a1-4.dyn; x=1656694071; h=Feedback-ID:
X-Smtpcorp-Track:Message-ID:Date:Subject:To:From:Reply-To:Sender:
List-Unsubscribe; bh=VGpVCtLdww32WC/o8WOiJX9gKmKYxwuluWxjkjjm0V8=; b=YtlbnmHm
06YekVfoH0rGV3OI4tGCyWBeKUYovWRGdX2narkup65G3q5UFvwz2fAOMgtWLrGz20ymyfyvxp9tQ
AHKzxa3DI9I3aI6RZw9PxYCMV+R5EQHOOCRAAmrNXn/awN93MUzy/EyFf4z1pfM8d2wqdJVNAuqM/
HS3M2wf4LxgBf0pobLKks6kklXZDAaa8Q/+n+yVhbcw9bl+n/0yyVu33nAfZ9TIuGgjF8iVDhQtCm
jT/pxv+tjDMn83PjlAawmWjihruGaOr1AaBov0sSSOjUMnTrSaNIHlNfCeABqcvsdcaPaCMT1m1cy
qLVA6On9l7kNN+ccXK60X7S78A==;
From: "David Allsopp" <David DOT Allsopp AT cl DOT cam DOT ac DOT uk>
To: <cygwin AT cygwin DOT com>
Subject: mmap failing with MAP_FIXED
Date: Fri, 1 Jul 2022 17:33:31 +0100
Organization: University of Cambridge
Message-ID: <000001d88d68$4d5a7a40$e80f6ec0$@cl.cam.ac.uk>
MIME-Version: 1.0
X-Mailer: Microsoft Outlook 16.0
Thread-Index: AdiNYuZTQLctL0iaTzeQdlxPaoakUg==
X-Scanned-By: MIMEDefang 2.65 on 62.31.23.242
X-Smtpcorp-Track: 1o7JZY9EFL-jVK.v5GxtkOb6aP4V
Feedback-ID: 614951m:614951apMmpqs:614951siNDrcKYaX
X-Report-Abuse: Please forward a copy of this message, including all headers,
to <abuse-report AT smtp2go DOT com>
X-Spam-Status: No, score=-1.7 required=5.0 tests=BAYES_00, DKIMWL_WL_MED,
DKIM_SIGNED, DKIM_VALID, DKIM_VALID_EF, HEADER_FROM_DIFFERENT_DOMAINS,
SPF_HELO_PASS, SPF_PASS, TXREP,
T_SCC_BODY_TEXT_LINE autolearn=no autolearn_force=no version=3.4.6
X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on
server2.sourceware.org
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-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>
Sender: "Cygwin" <cygwin-bounces+archive-cygwin=delorie DOT com AT cygwin DOT com>

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?

Thanks,


David


-- 
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

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019