aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohannes Kliemann <kliemann@adacore.com>2023-04-04 11:24:39 +0200
committerMarc Poulhiès <poulhies@adacore.com>2023-05-30 09:12:16 +0200
commit2a794b7750cbc9aa8b0c5778cc34b50a72e0f7a0 (patch)
tree8981cb0c6a405ab769b76757e4789d49c9de821d
parent53b05858fb070f3a21818d1649c73c9f90c6745a (diff)
downloadgcc-2a794b7750cbc9aa8b0c5778cc34b50a72e0f7a0.zip
gcc-2a794b7750cbc9aa8b0c5778cc34b50a72e0f7a0.tar.gz
gcc-2a794b7750cbc9aa8b0c5778cc34b50a72e0f7a0.tar.bz2
ada: Ensure Default_Stack_Size is greater than Minimum_Stack_Size
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.
-rw-r--r--gcc/ada/libgnat/s-parame.adb2
-rw-r--r--gcc/ada/libgnat/s-parame__rtems.adb2
-rw-r--r--gcc/ada/libgnat/s-parame__vxworks.adb11
3 files changed, 13 insertions, 2 deletions
diff --git a/gcc/ada/libgnat/s-parame.adb b/gcc/ada/libgnat/s-parame.adb
index 930c92d..6bd9f03 100644
--- a/gcc/ada/libgnat/s-parame.adb
+++ b/gcc/ada/libgnat/s-parame.adb
@@ -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;
diff --git a/gcc/ada/libgnat/s-parame__rtems.adb b/gcc/ada/libgnat/s-parame__rtems.adb
index 2f2e70b..1d51ae9 100644
--- a/gcc/ada/libgnat/s-parame__rtems.adb
+++ b/gcc/ada/libgnat/s-parame__rtems.adb
@@ -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;
diff --git a/gcc/ada/libgnat/s-parame__vxworks.adb b/gcc/ada/libgnat/s-parame__vxworks.adb
index 8e0768e..38fe022 100644
--- a/gcc/ada/libgnat/s-parame__vxworks.adb
+++ b/gcc/ada/libgnat/s-parame__vxworks.adb
@@ -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;