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:message-id:date:from:mime-version:to:subject :content-type:content-transfer-encoding; q=dns; s=default; b=ZON XIhm+6htMsOC+W3ab199Gi7vzFy/gelEOnP6KqBxStJeZ8aSo+/5i8jUqLCVkYo9 G5VV5z4vpNO1Ovif4AVPIpcYuJ5DA4dn/p+F7A0fIYTaIdVc8cldRAXlU6CBfSqR 16jcFdNs78Gf4ATQcCv8sCTpEzt5r9BESl7tsH+Y= 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:message-id:date:from:mime-version:to:subject :content-type:content-transfer-encoding; s=default; bh=Lkx+23Vjj WPNvC6rUxsRTmTJVP4=; b=D2t2thlzpeIhqRyAfhLmZFZdF+QVdwHXGwfHM8yAV nUtRZCTjgNfZ4S0EHyHkubROePa6jAYRhWfzuDJVaPMak3SQdHlP4gD5dKb/D/DZ iBmWRiH6rGHdwmdHzTsWTvaV5XG4Ww91B+14Y7U/G5AvHUJMqN09da/fOIdGeTKb Dc= 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 X-Spam-SWARE-Status: No, score=-3.2 required=5.0 tests=AWL,BAYES_00,KHOP_RCVD_UNTRUST,MAY_BE_FORGED,RCVD_IN_DNSWL_LOW,RP_MATCHES_RCVD,SPF_NEUTRAL autolearn=ham version=3.3.1 Message-ID: <5177CA05.3010500@cs.utoronto.ca> Date: Wed, 24 Apr 2013 08:03:17 -0400 From: Ryan Johnson User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:17.0) Gecko/20130328 Thunderbird/17.0.5 MIME-Version: 1.0 To: "cygwin AT cygwin DOT com" Subject: mmap(MAP_FIXED) vs mprotect Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Hi all, I'm trying to port a linux program that uses mmap to implement a growable array; the ideas is to mmap(PROT_NONE, MAP_NORESERVE) a chunk of address space (corresponding to the maximum array size) and then call mmap(PROT_READ|PROT_WRITE, MAP_FIXED) to allocate actual memory in the "blank" region. This works well in Linux but fails with EINVAL in cygwin. My code aligns all sizes up to 2MB boundaries, so it's not a 64kB boundary problem. My code reports the failing call as: > 22 Invalid argument addr=0xffdb0000, sz=2097152 A peek in /proc/self/maps confirms that the address is correct: > FFDB0000-FFFB0000 ===p 00000000 0000:0000 0 Oddly, trying to map in blank pages in with mprotect succeeds on cygwin but fails with ENOMEM on linux... Am I missing something here, or is this just a place where different behavior between the two platforms is a fact of life? Which version is the posixly "correct" way to reserve a chunk of address space and later back it with actual memory? Thanks, Ryan -- 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