* does gcc segfault when main memory is overfull?
@ 2013-09-17 19:22 Max B
2013-09-19 0:25 ` shouldn't gcc use swap space as temp storage?? Max B
0 siblings, 1 reply; 4+ messages in thread
From: Max B @ 2013-09-17 19:22 UTC (permalink / raw)
To: linux-mm@kvack.org
[-- Attachment #1: Type: text/plain, Size: 1092 bytes --]
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;
}
[-- Attachment #2: Type: text/html, Size: 4120 bytes --]
^ permalink raw reply [flat|nested] 4+ messages in thread
* shouldn't gcc use swap space as temp storage??
2013-09-17 19:22 does gcc segfault when main memory is overfull? Max B
@ 2013-09-19 0:25 ` Max B
2013-09-19 4:14 ` Vladimir Murzin
0 siblings, 1 reply; 4+ messages in thread
From: Max B @ 2013-09-19 0:25 UTC (permalink / raw)
To: linux-mm@kvack.org
[-- Attachment #1: Type: text/plain, Size: 1239 bytes --]
Hi All,
See below for executable program.
Shouldn't gcc use swap space as temp storage? Either my machine is set up improperly, or gcc does not (cannot?) access this capability.
It seems to me that programs should be able to access swap memory in these cases, but the behaviour has not been confirmed.
Can someone please confirm or correct me?
Apologies if this is not the correct listserv for the present discussion.
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;
}
[-- Attachment #2: Type: text/html, Size: 4353 bytes --]
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: shouldn't gcc use swap space as temp storage??
2013-09-19 0:25 ` shouldn't gcc use swap space as temp storage?? Max B
@ 2013-09-19 4:14 ` Vladimir Murzin
2013-09-21 3:13 ` Max B
0 siblings, 1 reply; 4+ messages in thread
From: Vladimir Murzin @ 2013-09-19 4:14 UTC (permalink / raw)
To: Max B; +Cc: linux-mm@kvack.org
On Thu, Sep 19, 2013 at 01:25:01AM +0100, Max B wrote:
>
>
>
>
>
>
> Hi All,
>
> See below for executable program.
>
>
> Shouldn't gcc use swap space as temp storage?? Either my machine is set up improperly, or gcc does not (cannot?) access this capability.
>
>
> It seems to me that programs should be able to access swap memory in these cases, but the behaviour has not been confirmed.
>
> Can someone please confirm or correct me?
>
It is not because your machine settings or gcc. Your code is buggy.
>
> Apologies if this is not the correct listserv for the present discussion.
>
I think the proper list for C related questions is linux-c-programming or similar.
Vladimir
>
> 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;
> }
--
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: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: shouldn't gcc use swap space as temp storage??
2013-09-19 4:14 ` Vladimir Murzin
@ 2013-09-21 3:13 ` Max B
0 siblings, 0 replies; 4+ messages in thread
From: Max B @ 2013-09-21 3:13 UTC (permalink / raw)
Cc: linux-mm@kvack.org
[-- Attachment #1: Type: text/plain, Size: 2794 bytes --]
Vladimir,
many thanks for pointing out that C99 is not my native tongue.
I plan to submit another segment of code -- this time in guaranteed non-buggy gfortran -- which shows similar behaviour to the buggy gcc code. In fact the code was originally conceived and written in gfortran, and I attempted (with evident failure as you so graciously point out) to translate it into gcc (seen below) for this linux-mm audience.
I hope to gain productive feedback on the causes of the observed behaviour , and its solution, at this listserv because 1) the gfortran code is not buggy and 2) I believe the linux-memory management listserv is the correct forum.
I gather that many on this newsgroup may not have installed gfortran by default, but quite possibly someone will be curious to see if s/he can replicate the observed behaviour, and either suggest a workaround or flag it as a feature.
Cheers,
Max
________________________________
De : Vladimir Murzin <murzin.v@gmail.com>
À : Max B <txtmb@yahoo.fr>
Cc : "linux-mm@kvack.org" <linux-mm@kvack.org>
Envoyé le : Jeudi 19 septembre 2013 6h14
Objet : Re: shouldn't gcc use swap space as temp storage??
On Thu, Sep 19, 2013 at 01:25:01AM +0100, Max B wrote:
>
>
>
>
>
>
> Hi All,
>
> See below for executable program.
>
>
> Shouldn't gcc use swap space as temp storage? Either my machine is set up improperly, or gcc does not (cannot?) access this capability.
>
>
> It seems to me that programs should be able to access swap memory in these cases, but the behaviour has not been confirmed.
>
> Can someone please confirm or correct me?
>
It is not because your machine settings or gcc. Your code is buggy.
>
> Apologies if this is not the correct listserv for the present discussion.
>
I think the proper list for C related questions is linux-c-programming or similar.
Vladimir
>
> 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;
> }
[-- Attachment #2: Type: text/html, Size: 7284 bytes --]
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2013-09-21 3:14 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-09-17 19:22 does gcc segfault when main memory is overfull? Max B
2013-09-19 0:25 ` shouldn't gcc use swap space as temp storage?? Max B
2013-09-19 4:14 ` Vladimir Murzin
2013-09-21 3:13 ` Max B
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 NNTP newsgroup(s).