g77 segmentation fault possible error allocating large arrays during runtime 
Author Message
 g77 segmentation fault possible error allocating large arrays during runtime

Hello,

Generally I have been using g77 when writing and debugging my programs,
but a different compiler (f77 on an IRIX machine) when running them.
My program compiles and runs fine using f77 on the IRIX.  It also compiles
fine using g77 but crashes when running with a segmentation fault.  After
some debugging it appears that the segmentation fault occurs after g77 has
allocated about 10MB of memory for use in arrays during runtime.  If I
change the size of the arrays used (my program integrates over a 2D grid)
and so it is easy to reduce the number of points on the grid) the program
will run fine using g77.  Also if I add arrays e.g. for temporary storage
of intermediate results the program will crash with a segmentation fault
at the start of the subroutine that allocates these new arrays (presuming
they are large enough).

Can anyone explain this since I prefer to use linux and g77 for
debugging(with ddd using gdb) and also i work quite a lot from home (linux).

I am guessing at this point that the program compiled with g77 can't
handle large arrays properly.  (I have over 256MB RAM on any machine I use
g77 with at work or at home.)

Thanks in advance.

Dave

p.s. i use only the option -g.  Also I have just attempted compilation
without the -g flag and adding the optimisation switch -O2 with the same
result.



Sat, 13 Jan 2007 21:13:38 GMT  
 g77 segmentation fault possible error allocating large arrays during runtime
First step in such cases is to check on limits (stacksizes and such) and to
remove them or increase them to the max.

Of course, there is also the possibility that there's a bug in your code and
that you access an array out of bounds, said access going to an invalid
address only in the case of larger array bounds.

        Jan



Sat, 13 Jan 2007 21:03:08 GMT  
 g77 segmentation fault possible error allocating large arrays during runtime

Quote:

> Hello,

> Generally I have been using g77 when writing and debugging my programs,
> but a different compiler (f77 on an IRIX machine) when running them.
> My program compiles and runs fine using f77 on the IRIX.  It also compiles
> fine using g77 but crashes when running with a segmentation fault.  After
> some debugging it appears that the segmentation fault occurs after g77 has
> allocated about 10MB of memory for use in arrays during runtime.  If I
> change the size of the arrays used (my program integrates over a 2D grid)
> and so it is easy to reduce the number of points on the grid) the program
> will run fine using g77.  Also if I add arrays e.g. for temporary storage
> of intermediate results the program will crash with a segmentation fault
> at the start of the subroutine that allocates these new arrays (presuming
> they are large enough).

This sort of problem usually indicates a bug in your code -- have you used
ftncheck and the runtime array bounds checking?  f77 on Irix is very old
-- are you runing Irix 5.3?  I use g77 on linux but f90 on Irix, which
allows me to use the f90 capabilities that have been implemented in g77.

Quote:
> Can anyone explain this since I prefer to use linux and g77 for
> debugging(with ddd using gdb) and also i work quite a lot from home (linux).

> I am guessing at this point that the program compiled with g77 can't
> handle large arrays properly.  (I have over 256MB RAM on any machine I use
> g77 with at work or at home.)

10MB is _NOT_ a large array by current standards.  Unless you are using
g77 and linux of the same vintage as your f77 compiler the chances that
this is a g77 bug are very small.

--

   Head of St. Margarets Bay, Nova Scotia, Canada



Sat, 13 Jan 2007 21:06:10 GMT  
 g77 segmentation fault possible error allocating large arrays during runtime
Hi George and Jan,

This is "bluemannequin" from my work address.  The above was the first
time I've posted to a news group.  Very pleasantly surprised by the
quickness of the response (i didn't expect any this soon hence the
comparative slowness of my reply).  Many thanks.  To business:

It was a problem with the stacksize.  On the IRIX machine it had already
been set to unlimited (but not on the linux machines).  Running the
following command fixed the problem:

limit stacksize unlimited

I added this also to my .cshrc file.

Thanks again,

Dave

Quote:

> First step in such cases is to check on limits (stacksizes and such) and to
> remove them or increase them to the max.

> Of course, there is also the possibility that there's a bug in your code and
> that you access an array out of bounds, said access going to an invalid
> address only in the case of larger array bounds.

>    Jan



Sun, 14 Jan 2007 20:54:13 GMT  
 g77 segmentation fault possible error allocating large arrays during runtime
Also...

limit stacksize unlimited only worked on the linux machines at work.  For
my home computer I had to use the command ulimit -s unlimited.

Cheers,

Dave



Mon, 15 Jan 2007 08:49:45 GMT  
 g77 segmentation fault possible error allocating large arrays during runtime

Quote:

> Also...

> limit stacksize unlimited only worked on the linux machines at work.  For
> my home computer I had to use the command ulimit -s unlimited.

> Cheers,

> Dave

That's probably because the work machines use [t]csh as the shell, while you
home machine uses [ba]sh. Each has a different syntax for setting limits.

cheers,

Rich

--
Dr Richard H D Townsend
Bartol Research Institute
University of Delaware

[ Delete VOID for valid email address ]



Mon, 15 Jan 2007 11:38:32 GMT  
 
 [ 6 post ] 

 Relevant Pages 

1. g77: segmentation fault with large arrays

2. Segmentation faults, array's, g77 and linux

3. Segmentation fault (Was: Runtime error in Forte compiled program)

4. Mystery: segmentation fault on allocate

5. g77 Segmentation Fault

6. Stack size, g77 and segmentation fault

7. Segmentation fault for medium-sized program on g77

8. Segmentation fault when increasing size of an array, fortran77

9. F90: segmentation fault with array intrinsics?

10. "address error" during allocate()

11. Segmentation Faults and Bus Errors

12. Segmentation fault error

 

 
Powered by phpBB® Forum Software