This patch causes exceptions propagated by the termination handler to be ignored, as required by the Ada RM. The following test should run to completion silently: with Ada.Task_Identification; with Ada.Task_Termination; use Ada.Task_Termination; with Ada.Exceptions; package Task_Term_Exc is task T; end Task_Term_Exc; package body Task_Term_Exc is
Some_Error : exception; protected Prot is procedure Termination_Handler (Cause : in Cause_Of_Termination; T : in Ada.Task_Identification.Task_Id; X : in Ada.Exceptions.Exception_Occurrence); end Prot; protected body Prot is procedure Termination_Handler (Cause : in Cause_Of_Termination; T : in Ada.Task_Identification.Task_Id; X : in Ada.Exceptions.Exception_Occurrence) is begin raise Some_Error; end Termination_Handler; end Prot; task body T is begin Set_Specific_Handler (T'Identity, Prot.Termination_Handler'Access); end T; end Task_Term_Exc; ---- date: 2011/05/27 18:00:38; author: duff; The test has no main procedure, so must be compiled with -z, as in "gnatmake -q -f -z -gnat2012 task_term_exc.adb". Tested on x86_64-pc-linux-gnu, committed on trunk 2011-08-29 Bob Duff <d...@adacore.com> * s-tassta.adb (Task_Wrapper): Handle and ignore exceptions propagated by the termination handler.
Index: s-tassta.adb =================================================================== --- s-tassta.adb (revision 178155) +++ s-tassta.adb (working copy) @@ -1324,7 +1324,14 @@ -- Execute the task termination handler if we found it if TH /= null then - TH.all (Cause, Self_ID, EO); + begin + TH.all (Cause, Self_ID, EO); + + exception + when others => + -- RM-C.7.3 requires these exceptions to be ignored + null; + end; end if; if System.Stack_Usage.Is_Enabled then