This is the mail archive of the cygwin-developers@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: munmap slowness; IsBadReadPtr considered harmful


On Feb 24 17:23, Brian Ford wrote:
> On Tue, 24 Feb 2004, Corinna Vinschen wrote:
> > 5.) No one has enough spare time currently.
> >
> Yeah, I hoped that was it.  But, I saw enough activity from you and Chris
> on the cygwin list about, IMHO, less interesting issues, that I wondered.

I must admit that my attention span is somewhat restricted currently.

> > AFAIU VirtualQuery, it returns information about consecutive pages
> > which share the same attributes.  So the length returned must be >=
> > the len parameter or you must check the actual attributes returned
> > by VirtualQuery.
> >
> Um, why must it be >= len?  I agree about checking the attributes, though.

Sorry, I didn't look into your function closely enough.  Scratch my
comment.

> I guess it all depends on your interpretation of the following lines from:
> 
> http://www.opengroup.org/onlinepubs/007904975/functions/munmap.html
> 
> ERRORS:
> 
> [EINVAL]
>     Addresses in the range [addr,addr+len) are outside the valid range for
> the address space of a process.
> 
> What does that *really* mean, especially in terms of
> COMMIT/RESERVE/FREE and NOACCESS/GUARD?

That's true.  On Linux, calling munmap on an already munmap'd memory
is no problem.  Even more interesting, regardless of the state of the
page allocation, all addresses valid as virtual memory addresses of
a process do not fail with munmap.

Since NOACCESS is used to mark munmapped pages in Cygwin's mmap
implementation, this would mean that munmapping an already munmapped
page would fail on Cygwin when checking for NOACCESS.  Testing reveals
that this is already the case right now so using IsBadReadPtr in this
context is actually wrong.  Oh boy.

I tested your first implementation of that function.  To say it in
simple words, the function only checks if the addresses are in the
valid virtual address space of the process.  I used it in the munmap
context and munmap behaves like on Linux now, only failing for addresses
outside the valid virtual address space of the process.

What I did is this:  I stripped the function to the bare minimum and
put it into miscfuncs.cc, called "check_invalid_virtual_addr".  Also
munmap now calls check_invalid_virtual_addr instead of IsBadReadPtr


Thanks,
Corinna

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


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