Subject: Re: Bus error - simple (?) C program
To: None <christos@zoulas.com>
From: Claude Marinier <claude.marinier@dreo.dnd.ca>
List: netbsd-help
Date: 09/10/2001 15:17:58
Christos,
Thanks. It is obvious now. I assumed that the array was static but it is
dynamic by default and allocated on the stack. I should have used malloc
or 'static'.
The following worked.
static float matrix[N][N];
On Mon, 10 Sep 2001 christos@zoulas.com wrote:
> Don't allocate the memory on the stack, use malloc instead. You can
> use ulimit [sh] or unlimit [csh] to increase the available stack size,
> but usually you have more space in the data segment.
>
> >#include <stdio.h>
> >#include <stdlib.h>
> >
> >#define N 10000
> >
> >int main( void )
> >{
> > int i;
> > float matrix[N][N];
> >
> > for ( i = 0; i < N; i++ ) {
> > matrix[i][i] = (float) random();
> > }
> >
> > return;
> >}
--
Claude Marinier, Information Technology Group claude.marinier@dreo.dnd.ca
Defence Research Establishment Ottawa (DREO) (613) 998-4901 FAX 998-2675
3701 Carling Avenue, Ottawa, Ontario K1A 0Z4 http://www.dreo.dnd.ca