delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2003/09/26/04:55:02

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
Mail-Followup-To: cygwin AT cygwin DOT com
Delivered-To: mailing list cygwin AT cygwin DOT com
Date: Fri, 26 Sep 2003 10:54:47 +0200
From: Corinna Vinschen <corinna-cygwin AT cygwin DOT com>
To: cygwin AT cygwin DOT com
Subject: Re: possible munmap bug
Message-ID: <20030926085447.GF22787@cygbert.vinschen.de>
Reply-To: cygwin AT cygwin DOT com
Mail-Followup-To: cygwin AT cygwin DOT com
References: <20030926015248 DOT 6464 DOT qmail AT linuxmail DOT org>
Mime-Version: 1.0
In-Reply-To: <20030926015248.6464.qmail@linuxmail.org>
User-Agent: Mutt/1.4.1i

On Fri, Sep 26, 2003 at 09:52:48AM +0800, peter garrone wrote:
> Hi,
>  This was causing my build of gcc to fail.
>  File winsup/cygwin/mmap.cc version 1.86 (and earlier) function munmap
>  when unmapping a 64K record, passes the wrong parameters to fhandler_base::munmap,
>  passing the function parameter address/length instead of a block local version.
> 
>  This patch explains it all.
> 
> diff -r -p -U 5 cygwin-snapshot-20030924-1/winsup/cygwin/mmap.cc new_cygwin/winsup/cygwin/mmap.cc
> --- cygwin-snapshot-20030924-1/winsup/cygwin/mmap.cc	2003-09-25 10:40:33.000000000 +1000
> +++ new_cygwin/winsup/cygwin/mmap.cc	2003-09-26 11:34:29.984375000 +1000
> @@ -679,11 +679,11 @@ munmap (void *addr, size_t len)
>  	  mmap_record *rec = map_list->get_record (record_idx);
>  	  if (rec->unmap_pages (u_addr, u_len))
>  	    {
>  	      /* The whole record has been unmapped, so... */
>  	      fhandler_base *fh = rec->alloc_fh ();
> -	      fh->munmap (rec->get_handle (), (caddr_t)addr, len);
> +	      fh->munmap (rec->get_handle (), (caddr_t)u_addr, u_len);
>  	      rec->free_fh (fh);
>  
>  	      /* ...delete the record. */
>  	      if (map_list->del_record (record_idx--))
>  		{
> 

Thanks for the headsup and the patch.  Actually I found that it's still
not quite correct.  Fhandler's munmap method should be called with the
same address and length which has been returned by a former call to
fhandler's mmap.  In Win32 terms:  UnmapViewOfFile has to be called
with the same address returned by a call to MapViewOfFile(Ex).  So in
the above code the munmap should be called like this:

  fh->munmap (rec->get_handle (), rec->get_address (), rec->get_size ());

since rec->get_address() returns exactly that address.  I've checked in
an appropriate patch.

Thanks again,
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
Problem reports:       http://cygwin.com/problems.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