This is the mail archive of the cygwin@cygwin.com mailing list for the Cygwin project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: mmap of large amount returns invalid pointer


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@cygwin.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/


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]