简体   繁体   English

Ubuntu与Red Hat错误

[英]Ubuntu vs. Red Hat errors

I have a C code which successfully runs under ubuntu, but when I am trying to run it on a red hat PC it is giving a "Segmentation fault (core dumped)" error. 我有一个可以在ubuntu下成功运行的C代码,但是当我尝试在红帽PC上运行它时,出现了“分段错误(内核已转储)”错误。 I have narrowed down the error to be from the following statement: 我已将错误缩小为以下声明:

long int encryption[800000][2];

this declaration is causing the code to crash. 此声明导致代码崩溃。

What can I do? 我能做什么? Any suggesstions? 任何建议? cheers =) 欢呼=)

Change it to 将其更改为

static long int encryption[800000][2];

Or make it global, or use malloc . 或使其全局,或使用malloc

Or use ulimit -s . 或使用ulimit -s

You are experiencing a stack overflow because the array is allocated on the stack. 您正在经历堆栈溢出,因为数组是在堆栈上分配的。

The size of the stack is platform defined, depends on the threading model and configuration, and on sysctl / ulimit settings (among others?). 堆栈的大小是平台定义的,取决于线程模型和配置,以及sysctl / ulimit设置(以及其他?)。

Make the array dynamically allocated or statically allocated ('global') to prevent this 使数组动态分配或静态分配('全局')以防止这种情况

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM