From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from psmtp.com (na3sys010amx114.postini.com [74.125.245.114]) by kanga.kvack.org (Postfix) with SMTP id 5B4266B0032 for ; Tue, 17 Sep 2013 15:22:13 -0400 (EDT) References: Message-ID: <1379445730.79703.YahooMailNeo@web172205.mail.ir2.yahoo.com> Date: Tue, 17 Sep 2013 20:22:10 +0100 (BST) From: Max B Reply-To: Max B Subject: does gcc segfault when main memory is overfull? MIME-Version: 1.0 Content-Type: multipart/alternative; boundary="-97308854-1164434340-1379445730=:79703" Sender: owner-linux-mm@kvack.org List-ID: To: "linux-mm@kvack.org" ---97308854-1164434340-1379445730=:79703 Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: quoted-printable =0A=0AHi All,=0A=0Adoes gcc segfault when main memory is overfull?=A0 See b= elow for executable program.=0A=0A=0AIt seems to me that programs should be= able to access swap memory in these cases, but the behaviour has not been = confirmed.=0A=0AIs this the correct listserv for the present discussion? Ap= ologies if not.=0A=0AThanks for any/all help.=0A=0A=0ACheers,=0AMax=0A=0A= =0A/*=0A=A0* This program segfaults with the *bar array declaration.=0A=A0*= =0A=A0* I wonder why it does not write the *foo array to swap space=0A=A0* = then use the freed ram to allocate *bar.=0A=A0*=0A=A0* I have explored the = shell ulimit parameters to no avail.=0A=A0*=0A=A0* I have run this as root = and in userland with the same outcome.=0A=A0*=0A=A0* It seems to be a probl= em internal to gcc, but may also be a kernel issue.=0A=A0*=0A=A0*/=0A=0A#in= clude =0A#include =0A=0A#define NMAX 628757505=0A=0Aint = main(int argc,char **argv) {=0A=A0 float *foo,*bar;=0A=0A=A0 foo=3Dcalloc(N= MAX,sizeof(float));=0A=A0 fprintf(stderr,"%9.3f %9.3f\n",foo[0],foo[1]);=0A= #if 1=0A=A0 bar=3Dcalloc(NMAX,sizeof(float));=0A=A0 fprintf(stderr,"%9.3f %= 9.3f\n",bar[0],bar[1]);=0A#endif=0A=0A=A0 return=0A 0;=0A}=0A ---97308854-1164434340-1379445730=:79703 Content-Type: text/html; charset=iso-8859-1 Content-Transfer-Encoding: quoted-printable

Hi Al= l,

does gcc segfault when main memory is overfull?&n= bsp; See below for executable program.

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

Is thi= s the correct listserv for the present discussion? Apologies if not.
<= div style=3D"color:rgb(0, 0, 0);font-size:13.3333px;font-family:times new r= oman, new york, times, serif;background-color:transparent;font-style:normal= ;">
Thanks for any/all hel= p.

Cheers,
Max

<= br>
/*
 * This = program segfaults with the *bar array declaration.
 *
 * I = wonder why it does not write the *foo array to swap space
 * then u= se the freed ram to allocate *bar.
 *
 * I have explored th= e shell ulimit parameters to no avail.
 *
 * I have run thi= s as root and in userland with the same outcome.
 *
 * It s= eems to be a problem internal to gcc, but may also be a kernel issue.
&n= bsp;*
 */

#include <stdio.h>
#include <stdlib.h&= gt;

#define NMAX 628757505

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

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

  return=0A 0;
}

---97308854-1164434340-1379445730=:79703-- -- To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to majordomo@kvack.org. For more info on Linux MM, see: http://www.linux-mm.org/ . Don't email: email@kvack.org