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:[EMAIL PROTECTED]
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/

Reply via email to