printf()导致核心转储 [英] printf() causes core dump

查看:74
本文介绍了printf()导致核心转储的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述




有谁可以告诉我为什么这个脚本file.c和file.h在编译和运行时会导致核心转换?b $ b转储?


任何帮助表示赞赏。

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

#定义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数组* /

int IBUFF [IBFLEN];


char CNAMES [64] [KELEM];

char CUNITS [24] [KELEM];

char CVALS [80] [KVALS];

浮动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\\\
);


返回1;

}

snip ....

解决方案

Sheldon写道:





任何人都可以告诉我为什么这个脚本file.c编译并运行时,file.h会导致核心

转储吗?


感谢任何帮助。

Sheldon



尝试使用更少的堆栈。可能你超出了允许的范围。


看看


ulimit -a

-

jacob navia

jacob at jacob point remcomp point fr

logiciels / informatique
http://www.cs.virginia.edu/~lcc-win32


2月27日21:18,Sheldon< shejo ... @ gmail.comwrote:





有谁可以告诉我为什么这个脚本file.c和file.h在编译和运行时会导致核心转换?b $ b转储? />

任何帮助表示赞赏。

Sheldon


snip ....


file.h:


#include< string.h>

#include< math.h>

#include< stdlib.h>

#include< stdio.h>

#include< dirent.h>

#包括< errno.h>

#include< ctyp e.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阵列* /

* 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 ];


*字符ID [8];


* int i,ii;


* printf(Testing\ n);


*返回1;}


snip ....



Thnaks,我会试一试。


/ S


Sheldon写道:


任何人都可以告诉我为什么这个脚本file.c和file.h在编译和运行时导致核心转换
转储?



BTW,C不是脚本语言。在这种情况下使用''脚本''

可能会让你嗤之以鼻,所以你可能不想这样做。无论如何


#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];



保证支持的数组限制远小于你b $ b尝试的数据。更糟糕的是,您正试图将它们分配为自动

变量。学习使用动态分配,或者可能使用静态数组。

你的主题行完全偏离基础:printf()无事可做

你的问题。并且将帖子内容分成

主题行和消息正文是愚蠢的。如果它值得一说,

它在消息正文中值得一说。


return 1;



1不是返回的便携值。更糟糕的是,您正在使用它来成功完成

。我们知道0是

成功完成的定义值之一,另一个是EXIT_SUCCESS。


}

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....

解决方案

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.

}


这篇关于printf()导致核心转储的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆