Hi,
Can anyone tell me why this script file.c and file.h causes a core
dump when it is compiled and run?
Any help is appreciated.
Sheldon
snip....
file.h:
#include <string.h>
#include <math.h>
#include <stdlib.h>
#include <stdio.h>
#include <dirent.h>
#include <errno.h>
#include <ctype.h>
#include <stdarg.h>
#include <sys/types.h>
#include "fort2c.h"
#define KELEM 500
#define KVALS 200000
#define IBFLEN 50000
char MODER[] = "r";
char FILNM[] = "string_path";
file.c:
#include "file.h"
int main() {
int IRET, ILEN, IUNIT1, IUNIT2, ILOOP, KERR;
int KTDLEN, KTDEXL;
/* 1D arrays */
int IBUFF[IBFLEN];
char CNAMES[64][KELEM];
char CUNITS[24][KELEM];
char CVALS[80][KVALS];
float VALUES[KVALS];
int KTDLST[KELEM];
int KTDEXP[KELEM];
int KSEC0[8];
int KSEC1[40];
int KSEC2[64];
int KEY[46];
int KSUP[9];
int KSEC3[4];
int KSEC4[2];
char ID[8];
int i, ii;
printf("Testing\n");
return 1;
}
snip.... 14 3813
Sheldon wrote:
Hi,
Can anyone tell me why this script file.c and file.h causes a core
dump when it is compiled and run?
Any help is appreciated.
Sheldon
Try to use less stack. Probably you are going beyond what
you are allowed.
Look at
ulimit -a
--
jacob navia
jacob at jacob point remcomp point fr
logiciels/informatique http://www.cs.virginia.edu/~lcc-win32
On 27 Feb, 21:18, Sheldon <shejo...@gmail.comwrote:
Hi,
Can anyone tell me why this script file.c and file.h causes a core
dump when it is compiled and run?
Any help is appreciated.
Sheldon
snip....
file.h:
#include <string.h>
#include <math.h>
#include <stdlib.h>
#include <stdio.h>
#include <dirent.h>
#include <errno.h>
#include <ctype.h>
#include <stdarg.h>
#include <sys/types.h>
#include "fort2c.h"
#define KELEM 500
#define KVALS 200000
#define IBFLEN 50000
char MODER[] = "r";
char FILNM[] = "string_path";
file.c:
#include "file.h"
int main() {
* int IRET, ILEN, IUNIT1, IUNIT2, ILOOP, KERR;
* int KTDLEN, KTDEXL;
* /* 1D arrays */
* int IBUFF[IBFLEN];
* char *CNAMES[64][KELEM];
* char *CUNITS[24][KELEM];
* char *CVALS[80][KVALS];
* float VALUES[KVALS];
* int * KTDLST[KELEM];
* int * KTDEXP[KELEM];
* int KSEC0[8];
* int KSEC1[40];
* int KSEC2[64];
* int KEY[46];
* int KSUP[9];
* int KSEC3[4];
* int KSEC4[2];
* char ID[8];
* int i, ii;
* printf("Testing\n");
* return 1;}
snip....
Thnaks, I will try it.
/S
Sheldon wrote:
Can anyone tell me why this script file.c and file.h causes a core
dump when it is compiled and run?
BTW, C is not a scripting language. Using 'script' in this context is
likely to earn you sneers, so you might not want to do that. In any case
#define KELEM 500
#define KVALS 200000
#define IBFLEN 50000
[...]
int main() {
[...]
int IBUFF[IBFLEN];
char CNAMES[64][KELEM];
char CUNITS[24][KELEM];
char CVALS[80][KVALS];
float VALUES[KVALS];
int KTDLST[KELEM];
int KTDEXP[KELEM];
int KSEC0[8];
int KSEC1[40];
int KSEC2[64];
int KEY[46];
int KSUP[9];
int KSEC3[4];
int KSEC4[2];
char ID[8];
The limits on arrays guaranteed to be supported is much smaller than you
are attempting. Even worse, you are trying to allocate them as auto
variables. Learn to use dynamic allocation or, possibly, static arrays.
Your subject line is completely off base: printf() has nothing to do
with your problem. And splitting the content of your post between
subject line and body of the message is silly. If it's worth saying,
it's worth saying in the body of the message.
return 1;
1 is not a portable value for return. Worse, you are using this for
successful completion. We know that 0 is one of the defined values for
successful completion, the other being EXIT_SUCCESS.
}
ri*****@cogsci.ed.ac.uk (Richard Tobin) writes:
There's nothing wrong in principle with having large
stack-allocated arrays.
I am not sure that I agree. Exhaustion of automatic storage is
not an event that a C program can detect and recover from.
Exhaustion of dynamically allocated storage, on the other hand,
is.
--
Peter Seebach on C99:
"[F]or the most part, features were added, not removed. This sounds
great until you try to carry a full-sized printout of the standard
around for a day."
In article <87************@blp.benpfaff.org>,
Ben Pfaff <bl*@cs.stanford.eduwrote:
>There's nothing wrong in principle with having large stack-allocated arrays.
>I am not sure that I agree. Exhaustion of automatic storage is not an event that a C program can detect and recover from.
That's true. If you're writing the kind of program where dealing
cleanly with that is important, it would certainly make sense to
prefer malloc().
-- Richard
--
:wq
Sheldon wrote:
>
Can anyone tell me why this script file.c and file.h causes a core
dump when it is compiled and run?
You have a serious stack overflow occurring.
--
[mail]: Chuck F (cbfalconer at maineline dot net)
[page]: <http://cbfalconer.home.att.net>
Try the download section.
--
Posted via a free Usenet account from http://www.teranews.com
On 27 Feb, 21:36, Martin Ambuhl <mamb...@earthlink.netwrote:
Sheldon wrote:
Can anyone tell me why this script file.c and file.h causes a core
dump when it is compiled and run?
BTW, C is not a scripting language. *Using 'script' in this context is
likely to earn you sneers, so you might not want to do that. *In any case
#define KELEM 500
#define KVALS 200000
#define IBFLEN 50000
[...]
int main() {
[...]
* int IBUFF[IBFLEN];
* char *CNAMES[64][KELEM];
* char *CUNITS[24][KELEM];
* char *CVALS[80][KVALS];
* float VALUES[KVALS];
* int * KTDLST[KELEM];
* int * KTDEXP[KELEM];
* int KSEC0[8];
* int KSEC1[40];
* int KSEC2[64];
* int KEY[46];
* int KSUP[9];
* int KSEC3[4];
* int KSEC4[2];
* char ID[8];
The limits on arrays guaranteed to be supported is much smaller than you
are attempting. *Even worse, you are trying to allocate them as auto
variables. *Learn to use dynamic allocation or, possibly, static arrays.
Your subject line is completely off base: printf() has nothing to do
with your problem. *And splitting the content of your post between
subject line and body of the message is silly. *If it's worth saying,
it's worth saying in the body of the message.
* return 1;
1 is not a portable value for return. *Worse, you are using this for
successful completion. *We know that 0 is one of the defined values for
successful completion, the other being EXIT_SUCCESS.
}- Dölj citerad text -
- Visa citerad text -- Dölj citerad text -
- Visa citerad text -
Thanks for the tips!
On 27 Feb, 23:42, CBFalconer <cbfalco...@yahoo.comwrote:
Sheldon wrote:
Can anyone tell me why this script file.c and file.h causes a core
dump when it is compiled and run?
You have a serious stack overflow occurring.
--
*[mail]: Chuck F (cbfalconer at maineline dot net)
*[page]: <http://cbfalconer.home.att.net>
* * * * * * Try the download section.
--
Posted via a free Usenet account fromhttp://www.teranews.com
Thanks everyone for your comments, critiques, and advice.
I am not a programmer so I don't do this very often and hence the
rookie mistakes.
Dynamic allocating of memory works. I am grateful :)
/Sheldon
In article <b2**********************************@e60g2000hsh. googlegroups.com>, Sheldon <sh******@gmail.comwrote:
>Hi,
Can anyone tell me why this script file.c and file.h causes a core dump when it is compiled and run?
[...]
>#define KVALS 200000
[...]
char CVALS[80][KVALS];
80 * 200000 = 16MB
Ya think you might be running out of stack space?
On Feb 27, 3:42*pm, CBFalconer <cbfalco...@yahoo.comwrote:
Sheldon wrote:
Can anyone tell me why this script file.c and file.h causes a core
dump when it is compiled and run?
You have a serious stack overflow occurring.
Gosh. Core dump. Stack trouble. Any pipes broken?
Oh I know ...linux.
Please comment further for those who aren't acquainted with whatever
strange reason you prefer it to windows. You're the definition of
topicality, Chuck.
--
Wade Ward <za*****@gmail.comwrites:
On Feb 27, 3:42Â*pm, CBFalconer <cbfalco...@yahoo.comwrote:
>Sheldon wrote:
Can anyone tell me why this script file.c and file.h causes a core
dump when it is compiled and run?
You have a serious stack overflow occurring.
Gosh. Core dump. Stack trouble. Any pipes broken?
Oh I know ...linux.
Please comment further for those who aren't acquainted with whatever
strange reason you prefer it to windows. You're the definition of
topicality, Chuck.
What in the world makes you think that stack overflows aren't a
problem on Windows?
And yes, stacks are not topical here. However, it was a helpful,
succint, and accurate response. Which also was not particularly
platform-specific.
The mention of core dumps, of course, is more platform-specific
(though hardly specific to Linux). But that wasn't Chuck, that was the
OP.
--
Micah J. Cowan
Programmer, musician, typesetting enthusiast, gamer... http://micah.cowan.name/
In article <fq**********@news.xmission.com>,
Kenny McCormack <ga*****@xmission.xmission.comwrote:
>In article <fq**********@pc-news.cogsci.ed.ac.uk>, Richard Tobin <ri*****@cogsci.ed.ac.ukwrote:
[...]
>>As Jacob indicated, there's probably a way to increase the stack available on your system. There's nothing wrong in principle with having large stack-allocated arrays.
>Note how a Clique member can say "the s-word" here and no one complains.
Am I a clique member? I never knew! Where do I get my badge?
-- Richard
--
:wq
In article <fq***********@pc-news.cogsci.ed.ac.uk>,
Richard Tobin <ri*****@cogsci.ed.ac.ukwrote:
>In article <fq**********@news.xmission.com>, Kenny McCormack <ga*****@xmission.xmission.comwrote:
>>In article <fq**********@pc-news.cogsci.ed.ac.uk>, Richard Tobin <ri*****@cogsci.ed.ac.ukwrote:
[...]
>>>As Jacob indicated, there's probably a way to increase the stack available on your system. There's nothing wrong in principle with having large stack-allocated arrays.
>>Note how a Clique member can say "the s-word" here and no one complains.
Am I a clique member? I never knew! Where do I get my badge?
Dunno about the badges, but, more or less by definition, if you can say
the "s-word" and not get stomped on, you must be in.
Richard Tobin wrote:
Kenny McCormack <ga*****@xmission.xmission.comwrote:
>Richard Tobin <ri*****@cogsci.ed.ac.ukwrote:
[...]
>>As Jacob indicated, there's probably a way to increase the stack available on your system. There's nothing wrong in principle with having large stack-allocated arrays.
>Note how a Clique member can say "the s-word" here and no one complains.
Am I a clique member? I never knew! Where do I get my badge?
Hold out your hand, palm down, and we will stamp it.
--
[mail]: Chuck F (cbfalconer at maineline dot net)
[page]: <http://cbfalconer.home.att.net>
Try the download section.
--
Posted via a free Usenet account from http://www.teranews.com This discussion thread is closed Replies have been disabled for this discussion. Similar topics
1 post
views
Thread by Martin |
last post: by
|
1 post
views
Thread by Jake |
last post: by
|
6 posts
views
Thread by John Liu |
last post: by
|
3 posts
views
Thread by John Liu |
last post: by
|
4 posts
views
Thread by Vincent |
last post: by
|
6 posts
views
Thread by wenmang |
last post: by
|
6 posts
views
Thread by Marvin Barley |
last post: by
|
4 posts
views
Thread by loudking |
last post: by
|
5 posts
views
Thread by johnericaturnbull |
last post: by
| | | | | | | | | | |