1. segmentation faults with large static arrays using gcc under RedHat 5.1
I'm having problems with large arrays. I am using gcc 2.7.2.3 to compile
on a machine running RedHat Linux 5.1.
I compile the program listed below like this:
gcc -o test_mem test_mem.c
I have defined dim1, dim2, dim3 to 128, then the
matrix[dim1][dim2][dim3] has 2^21 elements. In this case the source
compiles, but I get a runtime error: "Segmentation fault".
Decreasing, say, dim3 to 127, results in no compilation errors and no
runtime errors, that is, the program will run.
I have tried the same procedure on a Sun running Solaris 2.5.1 and the
same things happen.
The Sun has more than a GB of RAM, my machine 256 MB.
Is there some internal limitation set by gcc, or possibly in Unix? Is
there a way around that?
Your help is greatly appreciated.
Yours, Bob Wimmer
Here's the program:
#define dim1 128
#define dim2 128
#define dim3 128 //set dim3 to 127 to get code that doesn't result in
segmentation fault.
void main()
{
int matrix[dim1][dim2][dim3];
int i,j,k;
for (i = 0; i < dim1; i++)
{
for (j = 0; j < dim2; j++)
{
for (k = 0; k < dim3; k++)
{
matrix[i][j][k] = 1;
}
}
}
printf("programme terminated\n");
2. How many sun boxes in a BEA WLS cluster?
3. Star Office 5.1 - Segmentation Fault (core dump)
4. HP SureStore 4020i problems
5. RH 5.1 2.0.35 Kernel Seg Faults in rescue mode
6. STREAMS: create message
7. RH 5.0 with sb card yields segmentation fault - core dump
8. Cnews - is it obselete ?
9. rh 5.0 sndconfig yields segmentation fault - core dump
10. RH 4.2- Netscape Gold 3.0 Segmentation Fault
11. GhostScript 5.10-2 Segmentation fault
12. Segmentation faults with RH 5.0
13. Can a pgm compiled on RH 5.1 run on RH 4.2?