From patchwork Mon Aug 29 14:18:04 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnaud Charlet X-Patchwork-Id: 112065 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) by ozlabs.org (Postfix) with SMTP id 80D9BB6F95 for ; Tue, 30 Aug 2011 00:18:34 +1000 (EST) Received: (qmail 11677 invoked by alias); 29 Aug 2011 14:18:31 -0000 Received: (qmail 11451 invoked by uid 22791); 29 Aug 2011 14:18:29 -0000 X-SWARE-Spam-Status: No, hits=-1.8 required=5.0 tests=AWL,BAYES_00 X-Spam-Check-By: sourceware.org Received: from rock.gnat.com (HELO rock.gnat.com) (205.232.38.15) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Mon, 29 Aug 2011 14:18:05 +0000 Received: from localhost (localhost.localdomain [127.0.0.1]) by filtered-rock.gnat.com (Postfix) with ESMTP id B3E6F2BAFB5; Mon, 29 Aug 2011 10:18:04 -0400 (EDT) Received: from rock.gnat.com ([127.0.0.1]) by localhost (rock.gnat.com [127.0.0.1]) (amavisd-new, port 10024) with LMTP id gJmjf52cmq7N; Mon, 29 Aug 2011 10:18:04 -0400 (EDT) Received: from kwai.gnat.com (kwai.gnat.com [205.232.38.4]) by rock.gnat.com (Postfix) with ESMTP id 9FD6A2BAF37; Mon, 29 Aug 2011 10:18:04 -0400 (EDT) Received: by kwai.gnat.com (Postfix, from userid 4192) id 9DC0592A55; Mon, 29 Aug 2011 10:18:04 -0400 (EDT) Date: Mon, 29 Aug 2011 10:18:04 -0400 From: Arnaud Charlet To: gcc-patches@gcc.gnu.org Cc: Bob Duff Subject: [Ada] ignore exceptions in termination handlers Message-ID: <20110829141804.GA27082@adacore.com> MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.5.20 (2009-06-14) Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Delivered-To: mailing list gcc-patches@gcc.gnu.org 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 * 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