]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
ada: Ensure Default_Stack_Size is greater than Minimum_Stack_Size
authorJohannes Kliemann <kliemann@adacore.com>
Tue, 4 Apr 2023 09:24:39 +0000 (11:24 +0200)
committerMarc Poulhiès <poulhies@adacore.com>
Tue, 30 May 2023 07:12:16 +0000 (09:12 +0200)
The Default_Stack_Size function does not check that the binder specified
default stack size is greater than the minimum stack size for the runtime.
This can result in tasks using default stack sizes less than the minimum
stack size because the Adjust_Storage_Size only adjusts storages sizes for
tasks that explicitly specify a storage size. To avoid this, the binder
specified default stack size is round up to the minimum stack size if
required.

gcc/ada/

* libgnat/s-parame.adb: Check that Default_Stack_Size >=
Minimum_Stack_size.
* libgnat/s-parame__rtems.adb: Ditto.
* libgnat/s-parame__vxworks.adb: Check that Default_Stack_Size >=
Minimum_Stack_size and use the proper Minimum_Stack_Size if
Stack_Check_Limits is enabled.

gcc/ada/libgnat/s-parame.adb
gcc/ada/libgnat/s-parame__rtems.adb
gcc/ada/libgnat/s-parame__vxworks.adb

index 930c92d35e2d3c4336fabfec32f40e161c513e25..6bd9f03f63f6afb12b3699daeb01e6eb2168c415 100644 (file)
@@ -58,6 +58,8 @@ package body System.Parameters is
    begin
       if Default_Stack_Size = -1 then
          return 2 * 1024 * 1024;
+      elsif Size_Type (Default_Stack_Size) < Minimum_Stack_Size then
+         return Minimum_Stack_Size;
       else
          return Size_Type (Default_Stack_Size);
       end if;
index 2f2e70b1796956d2c87484c45017c73a8a432392..1d51ae9ec04d423fa04f5d5a7f7ee3b12641e84f 100644 (file)
@@ -63,6 +63,8 @@ package body System.Parameters is
    begin
       if Default_Stack_Size = -1 then
          return 32 * 1024;
+      elsif Size_Type (Default_Stack_Size) < Minimum_Stack_Size then
+         return Minimum_Stack_Size;
       else
          return Size_Type (Default_Stack_Size);
       end if;
index 8e0768e1e29d7f13cf8b7e3d1911738589cf5152..38fe0222622900e49d7018471000ef64f19368e5 100644 (file)
@@ -58,11 +58,13 @@ package body System.Parameters is
    begin
       if Default_Stack_Size = -1 then
          if Stack_Check_Limits then
-            return 32 * 1024;
             --  Extra stack to allow for 12K exception area.
+            return 32 * 1024;
          else
             return 20 * 1024;
          end if;
+      elsif Size_Type (Default_Stack_Size) < Minimum_Stack_Size then
+         return Minimum_Stack_Size;
       else
          return Size_Type (Default_Stack_Size);
       end if;
@@ -74,7 +76,12 @@ package body System.Parameters is
 
    function Minimum_Stack_Size return Size_Type is
    begin
-      return 8 * 1024;
+      if Stack_Check_Limits then
+         --  Extra stack to allow for 12K exception area.
+         return 20 * 1024;
+      else
+         return 8 * 1024;
+      end if;
    end Minimum_Stack_Size;
 
 end System.Parameters;