This patch fixes a bug in which if a Fall_Back_Handler is installed for the environment task, independent tasks will call it. The following test should run quietly:
with Ada.Text_IO; package body Debug is protected body Dbg is procedure Termination (Cause : in Task_Termination.Cause_Of_Termination; Task_Id : in Task_Identification.Task_Id; Except : in Exceptions.Exception_Occurrence) is begin Text_IO.Put_Line (Task_Identification.Image (Task_Id) & " " & Cause'Img); end Termination; end Dbg; end Debug; with Ada.Exceptions, Ada.Task_Termination, Ada.Task_Identification; use Ada; package Debug is protected Dbg is procedure Termination (Cause : in Task_Termination.Cause_Of_Termination; Task_Id : in Task_Identification.Task_Id; Except : in Exceptions.Exception_Occurrence); end Dbg; end Debug; with Ada.Real_Time.Timing_Events, Ada.Task_Termination, Debug; use Ada; procedure Pb_Terminate is begin Task_Termination.Set_Dependents_Fallback_Handler (Debug.Dbg.Termination'Access); end Pb_Terminate; Tested on x86_64-pc-linux-gnu, committed on trunk 2016-06-22 Bob Duff <d...@adacore.com> * s-tassta.adb (Task_Wrapper): Fix handling of Fall_Back_Handler wrt independent tasks.
Index: s-tassta.adb =================================================================== --- s-tassta.adb (revision 237680) +++ s-tassta.adb (working copy) @@ -6,7 +6,7 @@ -- -- -- B o d y -- -- -- --- Copyright (C) 1992-2014, Free Software Foundation, Inc. -- +-- Copyright (C) 1992-2016, Free Software Foundation, Inc. -- -- -- -- GNARL is free software; you can redistribute it and/or modify it under -- -- terms of the GNU General Public License as published by the Free Soft- -- @@ -1339,7 +1339,13 @@ if Self_ID.Common.Specific_Handler /= null then TH := Self_ID.Common.Specific_Handler; - else + + -- Independent tasks should not call the Fall_Back_Handler (of the + -- environment task), because they are implementation artifacts that + -- should be invisible to Ada programs. + + elsif Self_ID.Master_of_Task /= Independent_Task_Level then + -- Look for a fall-back handler following the master relationship -- for the task. As specified in ARM C.7.3 par. 9/2, "the fall-back -- handler applies only to the dependent tasks of the task". Hence,