X-Recipient: archive-cygwin AT delorie DOT com DomainKey-Signature: a=rsa-sha1; c=nofws; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:to:from:subject:message-id:date:mime-version :content-type:content-transfer-encoding; q=dns; s=default; b=svi dFEfe3nqCNKGaIaSURzZn1IggC5E/zgwYtmjEUU3KKIIOEJ5QWH6BJltBwYxN95E IYf1st3Y/6wYkd9aonuwKl3YBuo2ti3/pFavltnBVUP8agDDKee0/p/eBvteVJTC Z6/TeOP0DeMfIJdSdUKgGYcAnFmgp5hc9MdEUgTE= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:to:from:subject:message-id:date:mime-version :content-type:content-transfer-encoding; s=default; bh=Qch5AqoiU 8tN0xQ01kx2dIM+34U=; b=qHmCxGZhWr1D3ceG20aaamOEIxVxbooVJeNJz7mnG r5PFCiXrXXMaGmLZJQq46pEA6eSBnHDvCBJqsxWEUD3mG7Y7mNCXiMDvAqdb69KV 2h/Phsl0tTIZH0YyB2QPkoS17darLg72fzahJY5XGDvbDyaCFR3oYinGfedczVCt 50= Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: cygwin-owner AT cygwin DOT com Mail-Followup-To: cygwin AT cygwin DOT com Delivered-To: mailing list cygwin AT cygwin DOT com Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.4 required=5.0 tests=AWL,BAYES_00,SPF_HELO_PASS,SPF_PASS,T_RP_MATCHES_RCVD autolearn=ham version=3.3.2 spammy=H*MI:4618, H*M:4618 X-HELO: limerock02.mail.cornell.edu X-CornellRouted: This message has been Routed already. To: cygwin From: Ken Brown Subject: Atomic mmap replacement Message-ID: <66bf4f86-4618-b9a3-3e33-2c240b9204d0@cornell.edu> Date: Sat, 17 Feb 2018 22:37:03 -0500 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:52.0) Gecko/20100101 Thunderbird/52.6.0 MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit X-PMX-Cornell-Gauge: Gauge=XXXXX X-PMX-CORNELL-AUTH-RESULTS: dkim-out=none; X-IsSubscribed: yes Some code in emacs wants to reserve a chunk of address space with a big PROT_NONE anonymous mapping, and then carve it up into separate mappings associated to segments of a file. This fails on Cygwin. Here's a test case that illustrates the problem: $ truncate -s 64k foo $ cat mmap_test.c #include #include #include #include const size_t page_size = 64 * 1024; int main () { void *mem = mmap (NULL, 2 * page_size, PROT_NONE, MAP_PRIVATE | MAP_ANONYMOUS, -1, 0); if (mem == MAP_FAILED) { perror ("mmap"); exit (1); } int fd = open ("foo", O_RDONLY); void *res = mmap (mem, page_size, PROT_READ | PROT_WRITE, MAP_PRIVATE | MAP_FIXED, fd, 0); if (res == MAP_FAILED) { perror ("mmap"); exit (2); } } $ gcc mmap_test.c $ ./a mmap: Invalid argument $ echo $? 2 Is this a bug, or is it simply a limitation of Cygwin's mmap? If the latter, is there a simple workaround? Ken P.S. For context, you can start reading here, but it might not make a lot of sense: https://lists.gnu.org/archive/html/emacs-devel/2018-02/msg00440.html -- Problem reports: http://cygwin.com/problems.html FAQ: http://cygwin.com/faq/ Documentation: http://cygwin.com/docs.html Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple