public inbox for cygwin@cygwin.com
 help / color / mirror / Atom feed
* malloc segfaults
@ 2003-09-02 13:35 Juergen Bohn
  2003-09-02 20:51 ` Bill C. Riemers
                   ` (2 more replies)
  0 siblings, 3 replies; 5+ messages in thread
From: Juergen Bohn @ 2003-09-02 13:35 UTC (permalink / raw)
  To: cygwin

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/

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2003-09-04 11:03 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2003-09-02 13:35 malloc segfaults 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 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).