From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 28246 invoked by alias); 2 Sep 2003 13:35:43 -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 28041 invoked from network); 2 Sep 2003 13:35:14 -0000 Received: from unknown (HELO srvosc02.offis.uni-oldenburg.de) (134.106.50.2) by sources.redhat.com with SMTP; 2 Sep 2003 13:35:14 -0000 Received: from osc-es.de (nbosc15.OFFIS.Uni-Oldenburg.DE [134.106.50.71]) by srvosc02.offis.uni-oldenburg.de (8.11.3/8.11.3/SuSE Linux 8.11.1-0.5) with ESMTP id h82DTPs23741; Tue, 2 Sep 2003 15:29:25 +0200 Message-ID: <3F549C88.9040103@osc-es.de> Date: Tue, 02 Sep 2003 13:35:00 -0000 From: Juergen Bohn Organization: OSC Embedded Systems User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.4) Gecko/20030624 X-Accept-Language: en-us, en MIME-Version: 1.0 To: cygwin@cygwin.com Subject: malloc segfaults Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit X-SW-Source: 2003-09/txt/msg00125.txt.bz2 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 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). While testing, I detected that errno is set to 12 ("Not enough memory") after enough iterations through the for-loop above, while variable x still is not zero. But still my application crashes even when I break the loop at errno!=0. Is there any secure way to find out, how much memory is available (or hope that the malloc() problems will be solved)? Many thanks, Juergen -- 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/