473,404 Members | 2,137 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,404 software developers and data experts.

printf() causes core dump

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....
Feb 27 '08 #1
14 3942
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
Feb 27 '08 #2
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
Feb 27 '08 #3
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.
}
Feb 27 '08 #4
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."
Feb 27 '08 #5
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
Feb 27 '08 #6
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

Feb 27 '08 #7
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!
Feb 28 '08 #8
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
Feb 28 '08 #9
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?
Feb 28 '08 #10
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.
--
Feb 29 '08 #11
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/
Feb 29 '08 #12
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
Feb 29 '08 #13
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.

Feb 29 '08 #14
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

Feb 29 '08 #15

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Martin | last post by:
I use dbx and i got the following error: Reading GL_CliConnMgr core file header read successfully Reading ld.so.1 dbx: core file read error: address 0xff3e6000 not available dbx: core file...
1
by: Jake | last post by:
I have the following class definition #include <string> #include "embl.h" using namespace std; class Gene{ public: Gene(EMBL::EmblSaap *cdsinfo,int snp_pos); private: string codonseq;
6
by: John Liu | last post by:
I've two questions, they may or may not be related - 1. I copied the entire data directory from postgreSQL 7.3.2 (AIX4.3) to the installation postgreSQL 7.3.4 (AIX5.1), the same filesystem setup....
3
by: John Liu | last post by:
AIX pg version 7.4 Select * from document2 core dump. Did a few more experiments with select * from document2 limit... I limit to 500000 it works, 600000 it exits but says "calloc:...
4
by: Vincent | last post by:
Hello, Does anyone have a problem with Apache2 crashing after executing a PHP script with session_start()? I notice if session_start() is placed anywhere except at the start of the file, APache...
6
by: wenmang | last post by:
Here is the code which causes core dump when is built differently, 1 for regular dev built, the other for packaging build. class my_class{ public: my_class(){}; ~my_class(){}; private:...
6
by: Marvin Barley | last post by:
I have a class that throws exceptions in new initializer, and a static array of objects of this type. When something is wrong in initialization, CGI program crashes miserably. Debugging shows...
4
by: loudking | last post by:
Hi, all Here is part of my code. ======================================== void *record; /* treat record */ if (record) {
5
by: johnericaturnbull | last post by:
Hi - I am very new to python. I get this random core dump and am looking for a good way to catch the error. I know the function my core dump occurs. Is there any error catching/handling that I...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.