A few quick mmap questions

Ken Brown kbrown@cornell.edu
Fri Dec 20 22:48:21 GMT 2024


On 12/20/2024 10:37 AM, Corinna Vinschen wrote:
> No worries. The expression
> 
>    size_t commit_len = u_len - (start_addr - u_addr);
> 
> may be right, but it's not generally intelligible.  If you'd like
> to take a stab of changing the code to be more clear, I'm happy.
I'll give it a try.

By the way, the answer to my original question seems to be remarkably 
easy.  The question was whether we could allow mmap with MAP_FIXED to 
succeed if the requested area is contained in an existing anonymous 
mapping, even if the corresponding pages have not been unmapped first. 
If I'm not mistaken, all that's required is to delete the following 
lines starting at mmap.cc:497:

   /* First check if the area is unused right now. */
   for (SIZE_T l = 0; l < len; ++l)
     if (MAP_ISSET (off + l))
       {
	set_errno (EINVAL);
	return false;
       }

That seems to work in preliminary testing, but I'll have to test it more 
thoroughly before I'm sure.

If I convince myself that this works, is it OK with you if I commit it 
(to main only) while you're on vacation?  That way it can get wider 
testing, and I can always revert it if it breaks something.

Ken


More information about the Cygwin-developers mailing list