delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2002/03/14/07:32:59

Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm
List-Subscribe: <mailto:cygwin-subscribe AT cygwin DOT com>
List-Archive: <http://sources.redhat.com/ml/cygwin/>
List-Post: <mailto:cygwin AT cygwin DOT com>
List-Help: <mailto:cygwin-help AT cygwin DOT com>, <http://sources.redhat.com/ml/#faqs>
Sender: cygwin-owner AT cygwin DOT com
Delivered-To: mailing list cygwin AT cygwin DOT com
Date: Thu, 14 Mar 2002 13:22:23 +0100
From: Corinna Vinschen <cygwin AT cygwin DOT com>
To: cygwin AT cygwin DOT com
Subject: Re: mmap of large amount returns invalid pointer
Message-ID: <20020314132223.N29574@cygbert.vinschen.de>
Mail-Followup-To: cygwin AT cygwin DOT com
References: <20020313091122 DOT O29574 AT cygbert DOT vinschen DOT de> <15503 DOT 52045 DOT 291062 DOT 30208 AT asv-058 DOT sjc DOT ca DOT bbnow DOT net>
Mime-Version: 1.0
In-Reply-To: <15503.52045.291062.30208@asv-058.sjc.ca.bbnow.net>
User-Agent: Mutt/1.3.22.1i

On Wed, Mar 13, 2002 at 01:57:33PM -0800, Stephen Weeks wrote:
> I don't think this explanation is correct.  I still think that mmap is
> returning a pointer to an invalid chunk of memory.  To demonstrate
> this, here is a program that does an mmap, fprintf, and then attempts
> to write to the first byte of the mmap'ed memory.

The explanation wasn't quite correct, you're right, but the memory is
not invalid.  It's correctly returned by MapViewOfFileEx and the same
value is returned by mmap().  However, it's *non-accessible* since all
pages are protected using PAGE_NOACCESS after the call to MapViewOfFileEx.  
The next call to VirtualProtect which is responsible for setting the
correct protection mode on the used memory (used mem != allocated mem)
unfortunately fails.  The result is that mmap() returns a correct
memory pointer which is nevertheless inaccessible. :-(

Anyway, I've checked in a patch.  It now checks if VirtualProtect
failed and then mmap() also fails.  Try the next developers snapshot,
please.

Thanks for the testcases,
Corinna

-- 
Corinna Vinschen                  Please, send mails regarding Cygwin to
Cygwin Developer                                mailto:cygwin AT cygwin DOT com
Red Hat, Inc.

--
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple
Bug reporting:         http://cygwin.com/bugs.html
Documentation:         http://cygwin.com/docs.html
FAQ:                   http://cygwin.com/faq/

- Raw text -


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