Subject: Re: SIGSEGV error when using big float matrix under pvm
To: c5666305 <c5666305@comp.polyu.edu.hk>
From: David Brownlee <abs@anim.dreamworks.com>
List: current-users
Date: 05/17/1997 09:05:08
	You are almost certainly running out of stack space.

	You should be able to get more stack space by typing
	'unlimit stacksize'. On i386 this would increase the stack from
	512K to 8MB, and on the sparc from 512K to 64MB.

	The other (more correct) option would be to use malloc() or
	calloc(), but I dont know how to malloc multidimentional arrays
	offhand (other than to fudge it by allocating a single dimentional
	array and passing it into a function that expects a
	multidimentional array (uck))

	eg: Something like:

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

#define ARRAY_X         1024
#define ARRAY_Y         1024

void use_array(float[ARRAY_Y][ARRAY_X]);
main()
    {
    float       *array;

    if( (array=malloc(ARRAY_X*ARRAY_Y*sizeof(float)))==0 )
        {
        fputs("Unable to allocate space\n",stderr);
        exit(3);
        }
    use_array(array);
    }
    
void use_array(float array[ARRAY_Y][ARRAY_X])
    {
    /* The rest of the program */
    }


	I'd recommend unlimiting stacksize, or asking someone who knows
	more C than I do :)

                David/abs               abs@anim.dreamworks.com

.---- I've been too drunk to love ----.-- I've been too drunk to remember -.
|          too drunk to care          |    the hell of the night before    |
|  looked like death, felt like hell  |   I've been drinking myself blind  |
`------ been the worse for wear ------'-- and still I'll drink some more --'

On Sat, 17 May 1997, c5666305 wrote:

> Hello,
> 
> I am doing a project of parallel computing using the pvm software.  When I
> tried to declare a large float matrix with size 1024 * 1024, it resulted 
> segmentation fault in running the program.  If I use a float matrix with smaller
> size, it is ok.  Is there anyone have the clue ? I am running out of time.  
> Please help.  Thanks.
> 
> cheers
> 
> Clarence CHAN
>