From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-1.3 required=5.0 tests=BAYES_00,INVALID_MSGID autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,6be476fd23132bb7 X-Google-Attributes: gid103376,public From: William Paul Berriss Subject: Re: Ada program's use of Stack and Heap Date: 1997/04/20 Message-ID: <3359F8C2.791E@reading.ac.uk>#1/1 X-Deja-AN: 236122432 References: <335358C5.43F8@reading.ac.uk> <33548420.1046@reading.ac.uk> <3354B65D.124@reading.ac.uk> Organization: The University of Reading Newsgroups: comp.lang.ada Date: 1997-04-20T00:00:00+00:00 List-Id: Hi I use Solaris 2.5 on a Sun SPARC 5 , and GNAT Ada95 v3.05. I have got my programs to work now: From what I have done, I deduce the following (which may be only *almost* correct). When I declare an array that has any runtime determined sizes, then my program does NOT use the Stack - I proved this because if I make stack huge using Solaris 2.5 commands then my program will work ONLY if I fix all the array sizes at compile time. e.g. type Hist_Array is array( Pixel, Pixel, Pixel ) of Natural; where type Pixel is defined as a Natural range 0..255. BUT, if I decide on size at runtime then I get Segmentation Fault! If I use *new* I also get Segmentation Fault, for such a 64Megabyte array (even when I have limited stacksize to 2 gigabytes!). (Same goes for my C++ version incidently.) I can only presume that when I had a runtime size determined array, my program it was using the Heap? not the Stack, and hence threw up Segmentation Fault as the Heap was not big enough. Definitely not the stack anyway. And I cannot set the Heap limit (to my knowledge) using Solaris UNIX commands (e.g. limit) I have a number of programs that now work! Incidently, one of them did not work at first, it declared 3 of these huge arrays. It siad Segemntation Fault again, despite big stack size and fixed arrya size. The only difference with this program was that I had forgotton to use (others => (others => (others => 0 ))); when I declare the objects of this array type. As soon as I made this one change everything worked!!! When my program was *not* using *others*, it was as if the 64MB chunk of stack I declared was unusable because it was full of junk (not zeros). When I came to use file_io.read data into this array it gave me Segmentation Fault. (It was definitely the Read (i.e using the declared but unitialise array ) that threw up the error as I commented it out during a test.) With the comments removed and using others the others cured it! Odd? Anyway, that was how I got *my* program to work OK, as they now do, so it may be worth trying if you have the same problem? Feel free to add to this theory? or improve upon it! Will Berriss ------------ -- W P Berriss E-mail: W.P.Berriss@reading.ac.uk Department of Engineering The University of Reading Whiteknights Reading Tel: 0118 987 5123 Berkshire (+44 118 987 5123 outside UK) RG6 6AY England Fax: 0118 931 3327 World Wide Web Home Page: http://www.elec.rdg.ac.uk/people/postgrads/will.html