473,657 Members | 2,598 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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_pat h";

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 3970
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_pat h";

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.o rg>,
Ben Pfaff <bl*@cs.stanfor d.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...@earthl ink.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...@yah oo.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.co m
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************ *************** *******@e60g200 0hsh.googlegrou ps.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

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

Similar topics

1
3497
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 read error: address 0xff3e70a0 not available dbx: warning: could not initialize librtld_db.so.1 -- trying libDP_rtld_db.so Make sure this is the same version of Solaris where the core dump
1
1822
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
621
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. I didn't do an dump/reload process since the copy process is faster. Is it OK to take this shortcut in postgreSQL? any side-effects? 2. The copied database with 7.3.4 pgsql and 7.3.2 data dir seems running OK. But when I run the following...
3
2444
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: There is not
4
3184
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 will crash. Can anyone explain to me why? I don't want session_start to be at the start of the file because I need to override some session methods. So session_start has to happen after the declaration of custom session methods. Can anyone...
6
1712
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: string myData1;
6
3554
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 uncaught exception. How to catch an exception that happened before main() try { ... } catch (...) { ... } block? Is there a way?
4
8396
by: loudking | last post by:
Hi, all Here is part of my code. ======================================== void *record; /* treat record */ if (record) {
5
6087
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 could use in python?
0
8845
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8743
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8522
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8622
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
6177
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5647
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4173
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
2
1973
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1736
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.