Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

STORAGE_ERROR : EXCEPTION_STACK_OVERFLOW

20 views
Skip to first unread message

Robert C. Leif

unread,
Jul 8, 2005, 5:48:40 PM7/8/05
to Comp. Lang. Ada
I am creating software in Ada to visualize images obtained with a
fluorescence microscope. Unfortunately, when I switch my images from having
16 bit pixels to 32 bit pixels, I raise the exception STORAGE_ERROR :
EXCEPTION_STACK_OVERFLOW.
I am using GNAT 3.15p.
The Users Guide to Windows states: "5.3 Setting Stack Size from gnatlink
It is possible to specify the program stack size from gnatlink. Assuming
that the underlying linker is GNU ld there is two ways to do so:
using -Xlinker linker option
$ gnatlink hello -Xlinker --stack=0x10000,0x1000
This set the stack reserve size to 0x10000 bytes and the stack commit
size to 0x1000 bytes.
using -Wl linker option
$ gnatlink hello -Wl,--stack=0x1000000
This set the stack reserve size to 0x1000000 bytes. Note that with -Wl
option it is not possible to set the stack commit size because the coma is a
separator for this option."
My project file includes:

package Linker is
for Default_Switches ("ada") use ("-g", "-Xlinker
stack=0x10000000,0x10000000");
end Linker;

Even with a 10 megabyte stack, I still get Stack_Overflow.
Any suggestions would be greatly appreciated. I believe that I know how
to put the array on the heap using an access type. However, I greatly
prefer working with objects that are on the stack and omitting pointers from
my code.
Thank you.
Bob Leif

John B. Matthews

unread,
Jul 8, 2005, 11:52:22 PM7/8/05
to
In article <mailman.131.112085935...@ada-france.org>,

On one particular implementation derived from 3.15 sources, I had to use
the linker argument "-Xlstack= 10485760" to get 10 MB. You might look
at 'man ld' on your machine to see if there's an alternative.

As the requirements changed, I gave up and allocated space on the heap,
though.

--
John
jmatthews at wright dot edu
www dot wright dot edu/~john.matthews/

Marius Amado Alves

unread,
Jul 9, 2005, 5:27:55 AM7/9/05
to Robert C.Leif, Comp. Lang. Ada
What does this message mean EXCEPTION_STACK_OVERFLOW?

If it means overflow of a stack of exceptions, then isn't it possible
that your program has a logic fault that is exhausting that stack?

Robert C. Leif

unread,
Jul 9, 2005, 8:29:09 AM7/9/05
to comp.l...@ada-france.org
Marius Amado Alves wrote, "isn't it possible that your program has a

logic fault that is exhausting that stack?"
Since the original version with 16 bit pixels works and a new version
with 16 bit pixels and an access type for the two dimensional array works,
the existence of a logic fault that exhausts the stack is highly unlikely.
The access type version with 32 bit pixels executes. However, there appears
to be a problem with the creation of the normalized images, which have 8 bit
pixels. These 8 bit pixel images are critical because the dynamic range of
the human eye while looking at an image is of the order of 8 bits.
The real problem is that I can not use a standard, simple data-type (a
two dimensional array) for my program, which could be eventually used in a
medical device. I am presently forced to increase the complexity of my
program by the use of access types and consequently have decreased its
safety.
Hypothetically, if I find a sponsor with adequate funding to
commercialize this research technology, the next step would be to use SPARK,
which does not include access types. I suspect that there is a reasonable
consensus amongst the readers of Comp.Lang.Ada that Ada and SPARK are
excellent choices for medical imaging. Therefore, it would be very useful
to either create large objects on the stack or have the compiler put them on
the heap while maintaining the relatively simple syntax of a two dimensional
array type. In short, the compiler should permit me to maintain the
abstraction. Obviously under these circumstances, the use of a pragma would
be acceptable. Is there anything to be learned from Java technology where it
appears that simple data-types are put on the heap?
Bob Leif

------------------------------------------------------------------
Date: Sat, 9 Jul 2005 10:27:55 +0100
From: Marius Amado Alves <amado...@netcabo.pt>
Subject: Re: STORAGE_ERROR : EXCEPTION_STACK_OVERFLOW
To: Robert C.Leif <rl...@rleif.com>
Cc: "Comp. Lang. Ada" <comp.l...@ada-france.org>
Message-ID: <0374b45e755cd2fa...@netcabo.pt>
Content-Type: text/plain; charset=US-ASCII; format=flowed


What does this message mean EXCEPTION_STACK_OVERFLOW?

If it means overflow of a stack of exceptions, then isn't it possible
that your program has a logic fault that is exhausting that stack?

------------------------------

Duncan Sands

unread,
Jul 9, 2005, 3:14:44 PM7/9/05
to comp.l...@ada-france.org, rl...@rleif.com
> Even with a 10 megabyte stack, I still get Stack_Overflow.

Is this a multithreaded program?

D.

PS: I've heard it said that the default stack size is rather
small on windows, but I'm afraid I don't know how this relates
to GNAT/gcc.

Björn Persson

unread,
Jul 9, 2005, 6:55:14 PM7/9/05
to
Robert C. Leif wrote:
> $ gnatlink hello -Xlinker --stack=0x10000,0x1000

> for Default_Switches ("ada") use ("-g", "-Xlinker
> stack=0x10000000,0x10000000");

I notice the absence of two hyphens. Is that intentional?

--
Björn Persson PGP key A88682FD
omb jor ers @sv ge.
r o.b n.p son eri nu

Alex R. Mosteo

unread,
Jul 11, 2005, 6:15:29 AM7/11/05
to

You need to additionally use the pragma Storage_Size (...) in the tasks
at risk. If it's the main task, you may need to move everything to a
dummy task.

I have had success using this format: --Xlinker --stack=4000000,4000000

Keith Thompson

unread,
Jul 11, 2005, 4:07:09 PM7/11/05
to
"Robert C. Leif" <rl...@rleif.com> writes:
[...]

> Even with a 10 megabyte stack, I still get Stack_Overflow.

Unless you're using a very small, very old machine, 10 megabytes is
probably a tiny fraction of your total memory. Is there any reason
not to try 20 megabytes, or 100?

And as Alex R. Mosteo pointed out, you might also have to worry about
Storage_Size for tasks.

--
Keith Thompson (The_Other_Keith) ks...@mib.org <http://www.ghoti.net/~kst>
San Diego Supercomputer Center <*> <http://users.sdsc.edu/~kst>
We must do something. This is something. Therefore, we must do this.

jim hopper

unread,
Jul 11, 2005, 8:29:21 PM7/11/05
to

This probably means you have an Array in your program thats grown to
large to be stored as a stack based variable. the right thing to do is
to change this so that the variable is a pointer to an array then set
the point to "new <ARRAY>". this is pretty much transparent to the
rest of your code and it will force the array onto the heap and out of
the stack which allows you a MUCH larger data structure.

jim


In article <nospam-BBEA5F....@news-server.woh.rr.com>, John

0 new messages