does gcc segfault when main memory is overfull?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 




Hi All,

does gcc segfault when main memory is overfull?  See below for executable program.

It seems to me that programs should be able to access swap memory in these cases, but the behaviour has not been confirmed.

Is this the correct listserv for the present discussion? Apologies if not.

Thanks for any/all help.

Cheers,
Max


/*
 * This program segfaults with the *bar array declaration.
 *
 * I wonder why it does not write the *foo array to swap space
 * then use the freed ram to allocate *bar.
 *
 * I have explored the shell ulimit parameters to no avail.
 *
 * I have run this as root and in userland with the same outcome.
 *
 * It seems to be a problem internal to gcc, but may also be a kernel issue.
 *
 */

#include <stdio.h>
#include <stdlib.h>

#define NMAX 628757505

int main(int argc,char **argv) {
  float *foo,*bar;

  foo=calloc(NMAX,sizeof(float));
  fprintf(stderr,"%9.3f %9.3f\n",foo[0],foo[1]);
#if 1
  bar=calloc(NMAX,sizeof(float));
  fprintf(stderr,"%9.3f %9.3f\n",bar[0],bar[1]);
#endif

  return 0;
}


[Index of Archives]     [Linux ARM Kernel]     [Linux ARM]     [Linux Omap]     [Fedora ARM]     [IETF Annouce]     [Bugtraq]     [Linux]     [Linux OMAP]     [Linux MIPS]     [ECOS]     [Asterisk Internet PBX]     [Linux API]