From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from smtp1.atof.net (smtp1.atof.net [52.86.233.228]) by sourceware.org (Postfix) with ESMTPS id 375E63858D28 for ; Fri, 1 Jul 2022 16:45:45 +0000 (GMT) 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.com@gluelogic.com To: David Allsopp Cc: cygwin@cygwin.com Subject: Re: mmap failing with MAP_FIXED Message-ID: References: <000001d88d68$4d5a7a40$e80f6ec0$@cl.cam.ac.uk> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Content-Disposition: inline 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@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:45:46 -0000 On Fri, Jul 01, 2022 at 05:33:31PM +0100, David Allsopp wrote: > 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? Have you tried 'msync()' with MS_ASYNC flag as an alternative approach? Cheers, Glenn