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

Gnat storage size

439 views
Skip to first unread message

tmo...@acm.org

unread,
Aug 26, 2006, 2:09:56 PM8/26/06
to
What command line parameter do I need with Gnat 3.15p to increase the
main program's stack size? I'm getting
raised STORAGE_ERROR : big.adb:4 object too large
when the command line parameter is >= 4026 with the program:
with ada.command_line;
procedure big is
procedure try(k : in integer) is
x : array(1 .. k*1042) of integer;
begin
x(1) := 0;
end try;
begin
try(integer'value(ada.command_line.argument(1)));
end big;

Gautier

unread,
Aug 26, 2006, 2:46:37 PM8/26/06
to
tmo...@acm.org:

> What command line parameter do I need with Gnat 3.15p to increase the
> main program's stack size?

-largs -Wl,--stack=0x1000000

see the GNAT User's Guide: 5.3 Setting Stack Size from gnatlink
(e.g.:
http://beru.univ-brest.fr/~singhoff/DOC/LANG/ADA/gnat_ugn_6.html#SEC81
)

HTH, Gautier
______________________________________________________________
Ada programming -- http://www.mysunrise.ch/users/gdm/gsoft.htm

NB: For a direct answer, e-mail address on the Web site!

tmo...@acm.org

unread,
Aug 26, 2006, 3:26:56 PM8/26/06
to
> > What command line parameter do I need with Gnat 3.15p to increase the
> > main program's stack size?
>
> -largs -Wl,--stack=0x1000000
>
> see the GNAT User's Guide: 5.3 Setting Stack Size from gnatlink

gnatmake big -largs -Wl,--stack=0x1000000
works for a parameter of 4022 but gives:
raised STORAGE ERROR : EXCEPTION_STACK_OVERFLOW
with a parameter >= 4023, while either of
gnatmake big -largs -Wl,--stack=0x2000000
gnatmake big -largs -Wl,--stack=0x8000000
work for 4023 .. 4025 but 4026 again gives:

Kevin K

unread,
Aug 26, 2006, 6:42:28 PM8/26/06
to


First, what is OS are you interested in?

The normal way, going from memory, is:

...
end big;
pragma main(stack_size=>20000000); --for a 20 meg stack.

However there are caveats on some common platforms like the Mac and
Windows. With Windows you also have to do some linker arguments,
which should be explained in the GNAT documentation.

With OS X, my experimentation earlier this year shows a fairly limited
stack size, which make code using large stacks problematic.

For your example above, using access types would appear to be the best
solution. Then, it is less dependent on stack sizes, no matter the
OS.


--

Alex R. Mosteo

unread,
Aug 28, 2006, 2:26:07 AM8/28/06
to
tmo...@acm.org wrote:

Try moving your code out of the main task and giving a pragma Storage_Size
for the new task.

You still need the linker commands, however.

tmo...@acm.org

unread,
Aug 30, 2006, 3:53:46 AM8/30/06
to
So it appears that a simple program that does not use tasks or access
types is limited to under 4 megabytes of data with Gnat 3.15p on Windows?

Kevin K

unread,
Aug 30, 2006, 8:15:01 PM8/30/06
to

For what's it worth, I just installed Gnat 2006 for Windows, and
converted your test procedure. By using the -Xlinker
--stack=0x10000000 on it, I was able to successfully run big 64000 on
XP (technically, Tablet PC).

So either you need to use the -Xlinker variant, or there is a
limitation in the 3.15 version of the compiler. Or you are using an
older version of Windows that doesn't support this.

--

tmo...@acm.org

unread,
Aug 30, 2006, 9:42:35 PM8/30/06
to
> For what's it worth, I just installed Gnat 2006 for Windows, and
> converted your test procedure. By using the -Xlinker
> --stack=0x10000000 on it, I was able to successfully run big 64000 on
I tried
gnatmake big -largs -Xlinker --stack=0x10000000
and it still says "object too large" when the command line argument is 4026.
I also tried not using gnatmake, but rather
gcc -c big
gnatbind -x big.ali
gnatlink big -Wl --stack=0x10000000
with the same result.

Kevin K

unread,
Aug 31, 2006, 7:47:59 PM8/31/06
to

Then it is either your version of Windows (XP? 2000?), or the gnat
version.

--

Alex R. Mosteo

unread,
Sep 1, 2006, 9:24:30 AM9/1/06
to
tmo...@acm.org wrote:

> So it appears that a simple program that does not use tasks or access
> types is limited to under 4 megabytes of data with Gnat 3.15p on Windows?

This paragraph from the user's guide (2006 GPL edition) applies here. Check
the corresponding one of 3.15p.

"For declared tasks, the stack size is controlled by the size given in an
applicable Storage_Size pragma or by the value specified at bind time with
`-d' (see section 4.2 Switches for gnatbind) or is set to the default size
as defined in the GNAT runtime otherwise.

For the environment task, the stack size depends on system defaults and is
unknown to the compiler. Stack checking may still work correctly if a fixed
size stack is allocated, but this cannot be guaranteed. To ensure that a
clean exception is signalled for stack overflow, set the environment
variable GNAT_STACK_LIMIT to indicate the maximum stack area that can be
used, as in:"

0 new messages