public inbox for cygwin@cygwin.com
 help / color / mirror / Atom feed
From: Corinna Vinschen <corinna-cygwin@cygwin.com>
To: cygwin@cygwin.com
Subject: Re: malloc segfaults
Date: Thu, 04 Sep 2003 11:03:00 -0000	[thread overview]
Message-ID: <20030904110300.GA27802@cygbert.vinschen.de> (raw)
In-Reply-To: <3F549C88.9040103@osc-es.de>

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/

      parent reply	other threads:[~2003-09-04 11:03 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2003-09-02 13:35 Juergen Bohn
2003-09-02 20:51 ` Bill C. Riemers
2003-09-03 13:20   ` Christopher Faylor
     [not found] ` <20030903094303.GB19365@linux_rln.harvest>
2003-09-03 22:03   ` Juergen Bohn
2003-09-04 11:03 ` Corinna Vinschen [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20030904110300.GA27802@cygbert.vinschen.de \
    --to=corinna-cygwin@cygwin.com \
    --cc=cygwin@cygwin.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).