From patchwork Wed Jun 22 10:35:36 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnaud Charlet X-Patchwork-Id: 639086 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]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3rZLbf5BRcz9t0W for ; Wed, 22 Jun 2016 20:35:56 +1000 (AEST) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b=PcwIFfLG; dkim-atps=neutral DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:date :from:to:cc:subject:message-id:mime-version:content-type; q=dns; s=default; b=SajAlis2fVnbNw7GnpdgaCSotdWFyX/a9Un/OChySxyIi7pCxJ HuhPn0NvWN1+XETHnVGMsGY8MD0PN4oLziATaMQ1P0ilXj0PxDvI6eFLbIUcmyJk 8Ci0s6A/tLdiUOT0/JwgcY9kDRe6ZdorRY71MxYI1P0NRFY+OC8QzUtLQ= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:date :from:to:cc:subject:message-id:mime-version:content-type; s= default; bh=rThNuZ72JHgX/owfL9iX6wWCLaw=; b=PcwIFfLGq1AnC0eRipEY t3EMEDuyzdgoOKI+kAISp8YuaYhTKgKj87vSPdvfLs+cy1/1u6P7/QgD/AU7XgTt bwZwB7gMvqnBUFC3o63O2nBH+GAU6ShJ2ceZBaUnD3j62TR5z0OHuERYSeFK2Ye8 DXBFyIuNp67ilJyBBPCVX1I= Received: (qmail 40343 invoked by alias); 22 Jun 2016 10:35:49 -0000 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 Received: (qmail 39224 invoked by uid 89); 22 Jun 2016 10:35:48 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_NONE, SPF_PASS autolearn=ham version=3.3.2 spammy=bob, Bob, Duff, duff@adacore.com X-HELO: rock.gnat.com Received: from rock.gnat.com (HELO rock.gnat.com) (205.232.38.15) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES256-SHA encrypted) ESMTPS; Wed, 22 Jun 2016 10:35:37 +0000 Received: from localhost (localhost.localdomain [127.0.0.1]) by filtered-rock.gnat.com (Postfix) with ESMTP id 238D811665D; Wed, 22 Jun 2016 06:35:36 -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 qSBs9DPEKlc2; Wed, 22 Jun 2016 06:35:36 -0400 (EDT) Received: from tron.gnat.com (tron.gnat.com [IPv6:2620:20:4000:0:46a8:42ff:fe0e:e294]) by rock.gnat.com (Postfix) with ESMTP id 1013E116658; Wed, 22 Jun 2016 06:35:36 -0400 (EDT) Received: by tron.gnat.com (Postfix, from userid 4192) id 0D6C43F0; Wed, 22 Jun 2016 06:35:36 -0400 (EDT) Date: Wed, 22 Jun 2016 06:35:36 -0400 From: Arnaud Charlet To: gcc-patches@gcc.gnu.org Cc: Bob Duff Subject: [Ada] Independent tasks and the Fall_Back_Handler Message-ID: <20160622103536.GA7030@adacore.com> MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.5.23 (2014-03-12) 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 * 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,