From patchwork Fri Jan 13 10:23:23 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andre Vehreschild X-Patchwork-Id: 91299 Delivered-To: patch@linaro.org Received: by 10.140.20.99 with SMTP id 90csp120183qgi; Fri, 13 Jan 2017 02:23:59 -0800 (PST) X-Received: by 10.98.74.142 with SMTP id c14mr21989590pfj.139.1484303039477; Fri, 13 Jan 2017 02:23:59 -0800 (PST) Return-Path: Received: from sourceware.org (server1.sourceware.org. [209.132.180.131]) by mx.google.com with ESMTPS id n62si9219310pfb.57.2017.01.13.02.23.59 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 13 Jan 2017 02:23:59 -0800 (PST) Received-SPF: pass (google.com: domain of gcc-patches-return-446058-patch=linaro.org@gcc.gnu.org designates 209.132.180.131 as permitted sender) client-ip=209.132.180.131; Authentication-Results: mx.google.com; dkim=pass header.i=@gcc.gnu.org; spf=pass (google.com: domain of gcc-patches-return-446058-patch=linaro.org@gcc.gnu.org designates 209.132.180.131 as permitted sender) smtp.mailfrom=gcc-patches-return-446058-patch=linaro.org@gcc.gnu.org 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:in-reply-to:references :mime-version:content-type; q=dns; s=default; b=OPnGcGZ2X+kuSsVZ +K2z3vGx4YIpEjbH3oBykQ7OMel+kv8KgqeFD5g3zAfi9nZccWF2sVA1lqWbQ0pe t4nwvRbGUjBkhCTZTv9dLC2gJTMsj78rbrLBlbP8vSWUd6Cb7EMmp6PAq/TuF3lH 8IKhW41x64H53oPr9M2E8QBW39g= 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:in-reply-to:references :mime-version:content-type; s=default; bh=D7LnREZQdvVP+n34obsO7j X/1X0=; b=sIuGHpit8/oJcZM0YuHkw8a8vxWUK1NA47+qjgJaelPD65viTF91pr fR/++h9yK5cj+6AOxuSw+wCSuRLgEYxwXDVoFCYFue+iFFrByyc+0kjRtUKJUExx hhti1KdRIXpaIiPu6I0d/bX4BDNr9TAl8P+RfluMYIivnjbmaVBYQ= Received: (qmail 675 invoked by alias); 13 Jan 2017 10:23:43 -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 647 invoked by uid 89); 13 Jan 2017 10:23:42 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.8 required=5.0 tests=AWL, BAYES_00, FREEMAIL_FROM, KAM_ASCII_DIVIDERS, RCVD_IN_DNSWL_LOW, SPF_PASS autolearn=no version=3.3.2 spammy=nicht, Jerry, D*charter.net, delisle X-Spam-User: qpsmtpd, 2 recipients X-HELO: mout.gmx.net Received: from mout.gmx.net (HELO mout.gmx.net) (212.227.17.22) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Fri, 13 Jan 2017 10:23:32 +0000 Received: from vepi2 ([92.76.205.227]) by mail.gmx.com (mrgmx101 [212.227.17.168]) with ESMTPSA (Nemesis) id 0LeALI-1cmiqO1lXA-00psUP; Fri, 13 Jan 2017 11:23:24 +0100 Date: Fri, 13 Jan 2017 11:23:23 +0100 From: Andre Vehreschild To: Jerry DeLisle Cc: GCC-Patches-ML , GCC-Fortran-ML Subject: Re: [PATCH, Fortran, pr70696, v1] [Coarray] ICE on EVENT POST of host-associated EVENT_TYPE coarray Message-ID: <20170113112323.7aa27b42@vepi2> In-Reply-To: <1605333b-0420-0527-d766-b37e3355e860@charter.net> References: <20170112124558.6f8de516@vepi2> <1605333b-0420-0527-d766-b37e3355e860@charter.net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yOQdZDpUd/7wMKwTcxEAGHClH9dko3VdS2ThR ZQ== Hi Jerry, thanks for the review. Committed as r244407. Will backport to gcc-6 in a week or so. Regards, Andre On Thu, 12 Jan 2017 10:11:37 -0800 Jerry DeLisle wrote: > On 01/12/2017 03:45 AM, Andre Vehreschild wrote: > > Hi all, > > > > attached patch fixes the ICE when using an event in a subroutine. The reason > > for the ICE was that the backend_decl of the symbol to event on was not set > > when accessed. The patch ensures this. Furthermore did I fix a invalid > > memory access in the caf_single lib, where to less memory was allocated in > > the registration of the event. > > > > Bootstraps and regtests ok on x86_64-linux/F25. Ok for trunk? > > > > Regards, > > Andre > > > > OK and thanks. > > Jerry -- Andre Vehreschild * Email: vehre ad gmx dot de Index: gcc/fortran/ChangeLog =================================================================== --- gcc/fortran/ChangeLog (Revision 244394) +++ gcc/fortran/ChangeLog (Arbeitskopie) @@ -1,3 +1,9 @@ +2017-01-13 Andre Vehreschild + + PR fortran/70696 + * trans-expr.c (gfc_get_tree_for_caf_expr): Ensure the backend_decl + is valid before accessing it. + 2017-01-09 Jakub Jelinek PR translation/79019 Index: gcc/fortran/trans-expr.c =================================================================== --- gcc/fortran/trans-expr.c (Revision 244394) +++ gcc/fortran/trans-expr.c (Arbeitskopie) @@ -1838,6 +1838,10 @@ "component at %L is not supported", &expr->where); } + /* Make sure the backend_decl is present before accessing it. */ + if (expr->symtree->n.sym->backend_decl == NULL_TREE) + expr->symtree->n.sym->backend_decl + = gfc_get_symbol_decl (expr->symtree->n.sym); caf_decl = expr->symtree->n.sym->backend_decl; gcc_assert (caf_decl); if (expr->symtree->n.sym->ts.type == BT_CLASS) Index: gcc/testsuite/ChangeLog =================================================================== --- gcc/testsuite/ChangeLog (Revision 244394) +++ gcc/testsuite/ChangeLog (Arbeitskopie) @@ -1,3 +1,8 @@ +2017-01-13 Andre Vehreschild + + PR fortran/70696 + * gfortran.dg/coarray/event_3.f08: New test. + 2017-01-13 Richard Biener PR tree-optimization/77283 Index: gcc/testsuite/gfortran.dg/coarray/event_3.f08 =================================================================== --- gcc/testsuite/gfortran.dg/coarray/event_3.f08 (nicht existent) +++ gcc/testsuite/gfortran.dg/coarray/event_3.f08 (Arbeitskopie) @@ -0,0 +1,20 @@ +! { dg-do run } +! +! Check PR fortran/70696 is fixed. + +program global_event + use iso_fortran_env , only : event_type + implicit none + type(event_type) :: x[*] + + call exchange + contains + subroutine exchange + integer :: cnt + event post(x[1]) + event post(x[1]) + call event_query(x, cnt) + if (cnt /= 2) error stop 1 + event wait(x, until_count=2) + end subroutine +end Index: libgfortran/ChangeLog =================================================================== --- libgfortran/ChangeLog (Revision 244394) +++ libgfortran/ChangeLog (Arbeitskopie) @@ -1,3 +1,9 @@ +2017-01-13 Andre Vehreschild + + PR fortran/70696 + * caf/single.c (_gfortran_caf_register): Allocate enough memory for + the event counter. + 2017-01-07 Andre Vehreschild PR fortran/78781 Index: libgfortran/caf/single.c =================================================================== --- libgfortran/caf/single.c (Revision 244394) +++ libgfortran/caf/single.c (Arbeitskopie) @@ -141,9 +141,12 @@ caf_single_token_t single_token; if (type == CAF_REGTYPE_LOCK_STATIC || type == CAF_REGTYPE_LOCK_ALLOC - || type == CAF_REGTYPE_CRITICAL || type == CAF_REGTYPE_EVENT_STATIC - || type == CAF_REGTYPE_EVENT_ALLOC) + || type == CAF_REGTYPE_CRITICAL) local = calloc (size, sizeof (bool)); + else if (type == CAF_REGTYPE_EVENT_STATIC || type == CAF_REGTYPE_EVENT_ALLOC) + /* In the event_(wait|post) function the counter for events is a uint32, + so better allocate enough memory here. */ + local = calloc (size, sizeof (uint32_t)); else if (type == CAF_REGTYPE_COARRAY_ALLOC_REGISTER_ONLY) local = NULL; else