This is the mail archive of the mailing list for the Cygwin project.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: malloc segfaults Fixed

Thank you very much. It works.

Only one remark: errno is still much earlier set to 12 (Not enough memory)
than x=malloc(10000) is NULL.  I don't know if this is of interest.

Is it possible to get your patch as snapshot for 1.3.22 too?


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.



Unsubscribe info:
Problem reports:

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]