]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
ada: Fix use-after-free in Compute_All_Tasks
authorRonan Desplanques <desplanques@adacore.com>
Tue, 18 Mar 2025 12:56:58 +0000 (13:56 +0100)
committerMarc Poulhiès <dkm@gcc.gnu.org>
Tue, 10 Jun 2025 07:32:04 +0000 (09:32 +0200)
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.

gcc/ada/libgnarl/s-stusta.adb

index 5aca435e68c8bbb67f833947aa3ced735f3fbd1a..c9848a060c20be473a03a3eba1637947ca152c3f 100644 (file)
@@ -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;