public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
From: Pierre-Marie de Rodat <pmderodat@gcc.gnu.org>
To: gcc-cvs@gcc.gnu.org
Subject: [gcc r13-1619] [Ada] Ignore exceptions in task termination handlers
Date: Tue, 12 Jul 2022 12:25:05 +0000 (GMT)	[thread overview]
Message-ID: <20220712122505.DD2C63857365@sourceware.org> (raw)

https://gcc.gnu.org/g:fe6f256d5ba85a588493a489af1bdbe8087e368a

commit r13-1619-gfe6f256d5ba85a588493a489af1bdbe8087e368a
Author: Bob Duff <duff@adacore.com>
Date:   Mon Jun 20 13:59:03 2022 -0400

    [Ada] Ignore exceptions in task termination handlers
    
    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.

Diff:
---
 gcc/ada/libgnarl/s-solita.adb | 9 ++++++++-
 gcc/ada/libgnarl/s-taskin.ads | 2 +-
 gcc/ada/libgnarl/s-tassta.adb | 4 +---
 3 files changed, 10 insertions(+), 5 deletions(-)

diff --git a/gcc/ada/libgnarl/s-solita.adb b/gcc/ada/libgnarl/s-solita.adb
index 5bd66562b1d..dc0ce37cc52 100644
--- a/gcc/ada/libgnarl/s-solita.adb
+++ b/gcc/ada/libgnarl/s-solita.adb
@@ -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;
 
diff --git a/gcc/ada/libgnarl/s-taskin.ads b/gcc/ada/libgnarl/s-taskin.ads
index 2e6a0bb3bcf..b313b15391b 100644
--- a/gcc/ada/libgnarl/s-taskin.ads
+++ b/gcc/ada/libgnarl/s-taskin.ads
@@ -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 --
diff --git a/gcc/ada/libgnarl/s-tassta.adb b/gcc/ada/libgnarl/s-tassta.adb
index d6ed99ce9ba..8ba852e6707 100644
--- a/gcc/ada/libgnarl/s-tassta.adb
+++ b/gcc/ada/libgnarl/s-tassta.adb
@@ -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;


                 reply	other threads:[~2022-07-12 12:25 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20220712122505.DD2C63857365@sourceware.org \
    --to=pmderodat@gcc.gnu.org \
    --cc=gcc-cvs@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).