From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from e2i145.smtp2go.com (e2i145.smtp2go.com [103.2.140.145]) by sourceware.org (Postfix) with ESMTPS id 55171385AC3B for ; Fri, 1 Jul 2022 16:32:51 +0000 (GMT) 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==; Received: from [10.176.58.103] (helo=SmtpCorp) by smtpcorp.com with esmtpsa (TLS1.2:ECDHE_SECP256R1__RSA_SHA256__AES_256_GCM:256) (Exim 4.94.2-S2G) (envelope-from ) id 1o7JZZ-Y8PLJR-CV for cygwin@cygwin.com; Fri, 01 Jul 2022 16:32:49 +0000 Received: from [10.62.31.23] (helo=romulus.metastack.com) by smtpcorp.com with esmtpsa (TLS1.0:DHE_RSA_2038__AES_256_CBC__SHA1:256) (Exim 4.94.2-S2G) (envelope-from ) id 1o7JZY-9EFLeA-VK for cygwin@cygwin.com; Fri, 01 Jul 2022 16:32:49 +0000 Received: from Thor ([172.16.0.127]) (authenticated bits=0) by romulus.metastack.com (8.14.2/8.14.2) with ESMTP id 261GWkEJ021757 for ; Fri, 1 Jul 2022 17:32:46 +0100 From: "David Allsopp" To: 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 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit X-Mailer: Microsoft Outlook 16.0 Thread-Index: AdiNYuZTQLctL0iaTzeQdlxPaoakUg== Content-Language: en-gb 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 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@cygwin.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: General Cygwin discussions and problem reports List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 01 Jul 2022 16:32:53 -0000 This program fails at the second mmap call with EINVAL: #include #include #include 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