From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 1978 invoked by alias); 4 Sep 2003 11:03:01 -0000 Mailing-List: contact cygwin-help@cygwin.com; run by ezmlm Precedence: bulk List-Subscribe: List-Archive: List-Post: List-Help: , Sender: cygwin-owner@cygwin.com Mail-Followup-To: cygwin@cygwin.com Received: (qmail 1966 invoked from network); 4 Sep 2003 11:03:01 -0000 Received: from unknown (HELO cygbert.vinschen.de) (193.175.24.89) by sources.redhat.com with SMTP; 4 Sep 2003 11:03:01 -0000 Received: by cygbert.vinschen.de (Postfix, from userid 500) id 2C6495804E; Thu, 4 Sep 2003 13:03:00 +0200 (CEST) Date: Thu, 04 Sep 2003 11:03:00 -0000 From: Corinna Vinschen To: cygwin@cygwin.com Subject: Re: malloc segfaults Message-ID: <20030904110300.GA27802@cygbert.vinschen.de> Reply-To: cygwin@cygwin.com Mail-Followup-To: cygwin@cygwin.com References: <3F549C88.9040103@osc-es.de> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <3F549C88.9040103@osc-es.de> User-Agent: Mutt/1.4.1i X-SW-Source: 2003-09/txt/msg00268.txt.bz2 On Tue, Sep 02, 2003 at 03:35:04PM +0200, Juergen Bohn wrote: > Tested with cygwin1.dll 1.5.3-1 and 1.3.22-1 on Win2000-SP4, malloc() does > not (always) > return NULL if there is no more memory available. Try, for example, simple > loops like: > > x = malloc(10000); > for (i=0; x != NULL; i++) > { > x = malloc(10000); > if (x == NULL) printf("x is NULL\n"); > } > > My application terminates with a segmentation violation, but all attempts I've applied a patch to cygwin which solves this problem. You should get NULL at one point instead. > to handle this by signal() or atexit() fail. Unfortunately, also sysconf() > does not work to get the number of available pages (_SC_AVPHYS_PAGES, I get > always the same but wrong value). I've changed sysconf to return a more accurate value for _SC_AVPHYS_PAGES. However, this is not a value you can rely on. Cygwin processes might run out of memory even though there are still a lot of physical pages available. This is related to the fact that small allocations (less than 1 Meg) are taken from the applications heap which might be unraisable for some reason. Corinna -- Corinna Vinschen Please, send mails regarding Cygwin to Cygwin Developer mailto:cygwin@cygwin.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/