[AWS] Problem with stack limits

David Marceau davidmarceau@sympatico.ca
Thu, 04 Mar 2004 07:03:00 -0500


"Alejandro. R. Mosteo Chagoyen" wrote:
> 
> David,
> 
> thanks for all your suggestions. See my comments below.
> 
> Dicho por David Marceau:
> > OPTION #1
> > ----------
> > Taken from:
> > http://www.rtems.com/rtems/maillistArchives/rtems-users/2001/june/msg00155.html
> > I think I saw you mention something like this:
> > -- 2MB bytes allocated to instances of A_Task_Type
> > task type A_Task_Type;
> > for A_Task_Type'STORAGE_SIZE use 2_097_152;
> > A_Task : A_Task_Type;
> 
> This is Ada 83, right?
Judging by asking your question, your application is not behaving correctly and
when storage size above is specified.

Cohen's Ada bible p.997 states that it seems not obsolete:
"Ada95 uses an attibute-definition clause to specify the value of the
'Storage_Size attribute for an access type and a Storage_Size pragma to do so
for a task object."

You're right. You might also need to use:
pragma Storage_Size ( expression );
This had better work for you because I'm starting to run out of ideas :)

I checked this link and it seems to confirm what you said:
http://www.ada-auth.org/cgi-bin/cvsweb.cgi/AIs/AI-00059.TXT?rev=1.2
AND IT SAYS:
"It seems to me, that specifying the storage size of a task can no longer
be done using an attribute definition clause (for T'Storage_Size use
xxx), but the pragma Storage_size must be used.

Is this correct?  (No.)

!response

The "for T'Storage_Size" syntax can still be used -- see J.9.
The reason this was made obsolescent, and the pragma added,
is so that tasks of the same type can have different storage sizes.
Consider, for example:

    task type T(S_Size: Storage_Count) is
       pragma Storage_Size(S_Size);
    end T;

    X: T(10_000);
    Y: T(100_000);
"

I hope this helps a bit.

> 
> > OPTION #2
> > ---------
> >>--stack=0x10000
> >>4MB
> >>2MB
> > I recommend you use explicitly give a commit option also.
> > It seems you are just using the implicit default commit option by default(for
> > example 0x1000 which is 4K).
> > As it stands, explicitly you specified only the reserve option to 0x10000(hex) =
> > 65536 (decimal) Kbytes.
> 
> > Try explicitly stating both 1)reserve, 2)commit.
> > Humor me:
> > --stack=0x1000,0x1000
> > --stack=0x10000,0x10000
> > --stack=0x200000,0x200000
> > --stack=0x200000,0x200000
> > --stack=0x400000,0x400000
> 
> > Taken from:
> > http://www.cygwin.com/ml/cygwin/1997-08/msg00088.html
> 
> > gnatlink hello -Xlinker --stack=[reserve],[commit]
-Xlinker --stack=0x400000,0x400000

> I've noted that the -Xlinker argument is not recognized, though using
> -largs --stack... seem to work. [?]
Ok you succeeded to link with both resere and commit values explicitly
"--stack=0x...,0x...".
That's good I think.

Being that you succeeded to get your linker switches ok with -largs --stack, now
you really don't need to use Xlinker but I'll give this info anyways taken from
GCC 3.0 docs:
-Xlinker option 
      Pass option as an option to the linker. You can use this to supply
system-specific linker options which GCC does not know how to
      recognize. 

      If you want to pass an option that takes an argument, you must use
`-Xlinker' twice, once for the option and once for the
      argument. For example, to pass `-assert definitions', you must write
`-Xlinker -assert -Xlinker definitions'. It does not work to
      write `-Xlinker "-assert definitions"', because this passes the entire
string as a single argument, which is not what the linker
      expects. 

-Wl,<options>            Pass comma-separated <options> on to the linker
-Xlinker <arg>           Pass <arg> on to the linker

If you have to much trouble with -Wl or -Xlinker just do a verbose mode at the
compiler level and linker level to catch all the switches used and then use the
linker yourself and pass whatever switches directly :)  It's not the usual route
but it is a trick to get it to compile/link with your linker switches as a last
resort.

> 
> > OPTION #3
> > --------
> > You mentioned before:
> >>ulimit -s unlimited
> > What have you got for this?
> 
> I've verified I have unlimited stack size.
> 
> > OPTION ???
> > -----------
> > Any others ?:)
> > I can think of a drastic one by increasing a contant for STACK in libc and
> > recompiling it :)
> 
> That's something I hope I'll never need to attempt :)

Cheers,
David Marceau