For most operating systems, gcc
does not perform stack overflow
checking by default. This means that if the main environment task or
some other task exceeds the available stack space, then unpredictable
behavior will occur. Most native systems offer some level of protection by
adding a guard page at the end of each task stack. This mechanism is usually
not enough for dealing properly with stack overflow situations because
a large local variable could “jump” above the guard page.
Furthermore, when the
guard page is hit, there may not be any space left on the stack for executing
the exception propagation code. Enabling stack checking avoids
such situations.
To activate stack checking, compile all units with the gcc
option
-fstack-check
. For example:
$ gcc -c -fstack-check package1.adb
Units compiled with this option will generate extra instructions to check
that any use of the stack (for procedure calls or for declaring local
variables in declare blocks) does not exceed the available stack space.
If the space is exceeded, then a Storage_Error
exception is raised.
For declared tasks, the default stack size is defined by the GNAT runtime,
whose size may be modified at bind time through the -d
bind switch
(Switches for gnatbind). Task specific stack sizes may be set using the
Storage_Size
pragma.
For the environment task, the stack size is determined by the operating system. Consequently, to modify the size of the environment task please refer to your operating system documentation.