]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
[Ada] Ignore exceptions in task termination handlers
authorBob Duff <duff@adacore.com>
Mon, 20 Jun 2022 17:59:03 +0000 (13:59 -0400)
committerPierre-Marie de Rodat <derodat@adacore.com>
Tue, 12 Jul 2022 12:24:10 +0000 (12:24 +0000)
This patch fixes a bug in which if the environment task has a specific
termination handler, and that handler raises an exception, the handler
is called recursively, causing infinite recursion. The RM requires such
exceptions to be ignored.

gcc/ada/

* libgnarl/s-solita.adb (Task_Termination_Handler_T): Ignore all
exceptions propagated by Specific_Handler.
* libgnarl/s-tassta.adb, libgnarl/s-taskin.ads: Minor.

gcc/ada/libgnarl/s-solita.adb
gcc/ada/libgnarl/s-taskin.ads
gcc/ada/libgnarl/s-tassta.adb

index 5bd66562b1d1c153a2bf035d1a4ca9aad74916ff..dc0ce37cc523c85c0d8aeb52c5345de7bf77fcb0 100644 (file)
@@ -188,7 +188,14 @@ package body System.Soft_Links.Tasking is
       --  fall-back handler applies only to the dependent tasks of the task".
 
       if Self_Id.Common.Specific_Handler /= null then
-         Self_Id.Common.Specific_Handler.all (Cause, Self_Id, EO);
+         begin
+            Self_Id.Common.Specific_Handler.all (Cause, Self_Id, EO);
+         exception
+            --  RM-C.7.3(16) requires all exceptions raised here to be ignored
+
+            when others =>
+               null;
+         end;
       end if;
    end Task_Termination_Handler_T;
 
index 2e6a0bb3bcffd46609b67e958bc4481c66b1ddb1..b313b15391be51647661a6ed49d6b5b7d0e844f5 100644 (file)
@@ -1168,7 +1168,7 @@ package System.Tasking is
       --
       --  Protection: Self.L. Once a task has set Self.Stage to Completing, it
       --  has exclusive access to this field.
-   end record;
+   end record; -- Ada_Task_Control_Block
 
    --------------------
    -- Initialization --
index d6ed99ce9bacfcabd2353556fb7f56ff793b0336..8ba852e67077de4418215d2570562477acb9b0e7 100644 (file)
@@ -1307,10 +1307,8 @@ package body System.Tasking.Stages is
       if TH /= null then
          begin
             TH.all (Cause, Self_ID, EO);
-
          exception
-
-            --  RM-C.7.3 requires all exceptions raised here to be ignored
+            --  RM-C.7.3(16) requires all exceptions raised here to be ignored
 
             when others =>
                null;