aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRonan Desplanques <desplanques@adacore.com>2025-03-18 13:56:58 +0100
committerEric Botcazou <ebotcazou@adacore.com>2025-06-10 10:58:25 +0200
commit2859883e8901f5db7b26c07f823e2e8bc531a70d (patch)
tree2690b3a8585aa162244c505a7d3f248d75cd2f3d
parentba729e217add91ac919c06a51f00145249fbeb4b (diff)
downloadgcc-2859883e8901f5db7b26c07f823e2e8bc531a70d.zip
gcc-2859883e8901f5db7b26c07f823e2e8bc531a70d.tar.gz
gcc-2859883e8901f5db7b26c07f823e2e8bc531a70d.tar.bz2
ada: Fix use-after-free in Compute_All_Tasks
This patch fixes a bug in System.Stack_Usage.Tasking.Compute_All_Tasks where it would attempt to read the stack of threads that had already completed. gcc/ada/ChangeLog: * libgnarl/s-stusta.adb (Compute_All_Tasks): Skip terminated tasks.
-rw-r--r--gcc/ada/libgnarl/s-stusta.adb5
1 files changed, 4 insertions, 1 deletions
diff --git a/gcc/ada/libgnarl/s-stusta.adb b/gcc/ada/libgnarl/s-stusta.adb
index 5aca435..c9848a0 100644
--- a/gcc/ada/libgnarl/s-stusta.adb
+++ b/gcc/ada/libgnarl/s-stusta.adb
@@ -32,6 +32,7 @@
-- This is why this package is part of GNARL:
with System.Tasking.Debug;
+with System.Tasking.Stages;
with System.Task_Primitives.Operations;
with System.IO;
@@ -103,7 +104,9 @@ package body System.Stack_Usage.Tasking is
-- Calculate the task usage for a given task
- Report_For_Task (Id);
+ if not System.Tasking.Stages.Terminated (Id) then
+ Report_For_Task (Id);
+ end if;
end loop;
end if;