[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Bug#334942: gcc-4.0-base: Large local arrays in function lead to segmentation fault



Package: gcc-4.0-base
Version: 4.0.2-2
Severity: important

When I compile and run the following program the definition of the
arrays in the function leads to a segmentation fault when I try to
access the "i" array. gdb tells me "Cannot access memeory address"

Here is a minimal test program that shows the error (at least on my
system):


#include <stdio.h>
#include <stdlib.h>

#define xdim 1000
#define ydim 1000

void analysis(){
  double ddphi[xdim][ydim],mu[xdim][ydim];
  int i[3];

  i[1]=1;
}

int main(int argc, char *argv[]){

  analysis();
  return 0;
}
	  

Presumably a work around is to avoid large local arrays and to replace
them with global arrays, or if there is not enough space with allocated
pointers. But I use these programs while teaching Physics, and the first
option makes the programs less readable and the second option excceds
the ability of many students.

-- System Information:
Debian Release: testing/unstable
  APT prefers unstable
  APT policy: (500, 'unstable')
Architecture: i386 (i686)
Shell:  /bin/sh linked to /bin/bash
Kernel: Linux 2.6.12-1-k7-smp
Locale: LANG=C, LC_CTYPE=C (charmap=ANSI_X3.4-1968)

-- no debconf information



Reply to: