delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2009/11/09/06:59:24

X-Recipient: archive-cygwin AT delorie DOT com
X-Spam-Check-By: sourceware.org
Date: Mon, 9 Nov 2009 12:59:03 +0100
From: Corinna Vinschen <corinna-cygwin AT cygwin DOT com>
To: cygwin AT cygwin DOT com
Subject: Re: Broken autoconf mmap test (was Re: 1.7] BUG - GREP slows to a crawl with large number of matches on a single file)
Message-ID: <20091109115903.GE26344@calimero.vinschen.de>
Reply-To: cygwin AT cygwin DOT com
Mail-Followup-To: cygwin AT cygwin DOT com
References: <20091108141548 DOT GB26344 AT calimero DOT vinschen DOT de> <4AF716DB DOT 8060904 AT cwilson DOT fastmail DOT fm>
MIME-Version: 1.0
In-Reply-To: <4AF716DB.8060904@cwilson.fastmail.fm>
User-Agent: Mutt/1.5.20 (2009-06-14)
Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm
List-Id: <cygwin.cygwin.com>
List-Unsubscribe: <mailto:cygwin-unsubscribe-archive-cygwin=delorie DOT com AT cygwin DOT com>
List-Subscribe: <mailto:cygwin-subscribe AT cygwin DOT com>
List-Archive: <http://sourceware.org/ml/cygwin/>
List-Post: <mailto:cygwin AT cygwin DOT com>
List-Help: <mailto:cygwin-help AT cygwin DOT com>, <http://sourceware.org/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

On Nov  8 14:07, Charles Wilson wrote:
> Corinna Vinschen wrote:
> > On Nov  8 14:56, Corinna Vinschen wrote:
> >> Btw., the check for mmap in grep's configure file is broken.  It tries
> >> to mmap to a fixed address formerly allocated via malloc().  This doesn't
> >> work on Windows.  An autoconf run with a newer version of autoconf would
> >> be nice.
> > 
> > I just found that the latest autoconf *still* has this broken test
> > for mmap, which basically calls
> > 
> >   data2 = malloc (size);
> >   mmap(data2, ...);
> > 
> > Why has this test never been fixed?  Chuck?
> 
> ...err, 'cause I didn't realize it was a problem. I see that cygport has
> hidden this for years:
> 
>     # AC_HAVE_MMAP fails despite a working mmap, so we force this to yes
>     # (see http://www.cygwin.com/ml/cygwin/2004-09/msg00741.html
>     # and following thread for details)
>     export ac_cv_func_mmap_fixed_mapped=yes;
> 
> NTTAWWT, but it never triggered my "gee I ought to fix that" reflex. I
> agree this should be fixed, but I'm leery of changing an autoconf test
> without knowing how that change will affect the other 9,236 platforms

The problem in this testcase is the fact that it calls malloc, then
computes the next page-aligned free address after the mallocated area
and then tries to mmap to this address with MAP_FIXED set.  Sure, this
*might* work, and it works on most systems, but there's no reason at all
to *expect* that it works since it only works by chance.  The memory
addresses can be taken by anything and to require that an arbitrary
fixed address is available to mmap is just plain wrong.  From the
Linux man page:

MAP_FIXED
  [...]
  If the specified address cannot be used, mmap() will fail.  Because
  requiring a fixed address for a mapping is less portable, the use of
  this option is discouraged.

Since autoconf is supposed to help applications to be more portable,
it's not really feasible, IMHO, that autoconf requires a non-portable
feature to work.

It's frustrating that mmap() and even mmap(MAP_FIXED)
works fine on Cygwin, just not in the non-portable way it's tested
in the autoconf test.  Maybe we need two mmap tests in autconf, one
for mmap in general, the other for MAP_FIXED iisues.

> I think this is an issue for the autoconf list as a whole.  Would you --
> or Eric -- care to raise it there?  Especially as you seemed to have
> quite strong feelings about it back in 2004:
> http://www.cygwin.com/ml/cygwin/2004-09/msg00753.html

I had hoped that you, as the autoconf maintainer, would put this
upstream...


Corinna

-- 
Corinna Vinschen                  Please, send mails regarding Cygwin to
Cygwin Project Co-Leader          cygwin AT cygwin DOT com
Red Hat

--
Problem reports:       http://cygwin.com/problems.html
FAQ:                   http://cygwin.com/faq/
Documentation:         http://cygwin.com/docs.html
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019