From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 117757 invoked by alias); 1 Oct 2015 13:29:12 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Received: (qmail 117739 invoked by uid 89); 1 Oct 2015 13:29:11 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.2 required=5.0 tests=AWL,BAYES_00,RCVD_IN_DNSWL_LOW,SPF_PASS,T_RP_MATCHES_RCVD autolearn=ham version=3.3.2 X-Spam-User: qpsmtpd, 2 recipients X-HELO: smtp25.services.sfr.fr Received: from smtp25.services.sfr.fr (HELO smtp25.services.sfr.fr) (93.17.128.119) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES256-SHA encrypted) ESMTPS; Thu, 01 Oct 2015 13:29:10 +0000 Received: from filter.sfr.fr (localhost [86.72.15.181]) by msfrf2512.sfr.fr (SMTP Server) with ESMTP id 4D0147000061; Thu, 1 Oct 2015 15:29:07 +0200 (CEST) Authentication-Results: sfrmc.priv.atos.fr; dkim=none (no signature); dkim-adsp=none (no policy) header.from=mikael.morin@sfr.fr Received: from [192.168.1.86] (181.15.72.86.rev.sfr.net [86.72.15.181]) (using TLSv1 with cipher DHE-RSA-AES128-SHA (128/128 bits)) (No client certificate requested) by msfrf2512.sfr.fr (SMTP Server) with ESMTP id 85080700009C; Thu, 1 Oct 2015 15:29:06 +0200 (CEST) X-SFR-UUID: 20151001132906545.85080700009C@msfrf2512.sfr.fr From: Mikael Morin Subject: Re: [PATCH] fortran/67758 -- Prevent ICE caused by misplaced COMMON To: Steve Kargl , fortran@gcc.gnu.org, gcc-patches@gcc.gnu.org References: <20151001000630.GB73614@troutmask.apl.washington.edu> <20151001000740.GC73614@troutmask.apl.washington.edu> <560D240C.5070405@sfr.fr> Message-ID: <560D3521.5050406@sfr.fr> Date: Thu, 01 Oct 2015 13:29:00 -0000 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.2.0 MIME-Version: 1.0 In-Reply-To: <560D240C.5070405@sfr.fr> Content-Type: multipart/mixed; boundary=------------010803080100060503000205 X-IsSubscribed: yes X-SW-Source: 2015-10/txt/msg00059.txt.bz2 This is a multi-part message in MIME format. --------------010803080100060503000205 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 8bit Content-length: 1332 Le 01/10/2015 14:16, Mikael Morin a écrit : > Le 01/10/2015 02:07, Steve Kargl a écrit : >> On Wed, Sep 30, 2015 at 05:06:30PM -0700, Steve Kargl wrote: >>> Patch built and regression tested on x86_64-*-freebsd. >>> OK to commit? >>> >>> The patch prevents the dereferencing of a NULL pointer >>> by jumping out of the cleanup of a list of COMMON blocks. >>> > Hold on, I believe p should be present in the common symbol list pointed > by p->common. s/p->common/p->common_block/ > And by the way, if we are in gfc_restore_last_undo_checkpoint, we have > found something bogus enough to backtrack, so hopefully an error has > already been prepared (but maybe not emitted). > I will investigate more. > It seems the error [1] is reported in gfc_add_in_common, between the time the symbol's common_block pointer is set and the time the symbol is added to the list. As the program goes straight to clean-up/return upon error, this interim state is not fixed and poses problem. So we need to reduce the interim time to zero or fix the state upon error. I propose the following, which delays setting the common_block after error_checking (I believe it is not used in that time). Regression-tested on x86_64-unknown-linux-gnu. OK for trunk? Mikael [1] Error: PROCEDURE attribute conflicts with COMMON attribute in 'xx' at (1) --------------010803080100060503000205 Content-Type: text/plain; charset=UTF-8; name="pr67758_v2.CL" Content-Transfer-Encoding: base64 Content-Disposition: attachment; filename="pr67758_v2.CL" Content-length: 358 MjAxNS0xMC0wMSAgTWlrYWVsIE1vcmluICA8bWlrYWVsQGdjYy5nbnUub3Jn PgoKCVBSIGZvcnRyYW4vNjc3NTgKCSogbWF0Y2guYyAoZ2ZjX21hdGNoX2Nv bW1vbik6IERlbGF5IHRoZSBjb21tb25fYmxvY2sgcG9pbnRlcgoJYXNzaWdu bWVudCBhZnRlciBlcnJvciBjaGVja2luZy4KCjIwMTUtMTAtMDEgIE1pa2Fl bCBNb3JpbiAgPG1pa2FlbEBnY2MuZ251Lm9yZz4KCglQUiBmb3J0cmFuLzY3 NzU4CgkqIGdmb3J0cmFuLmRnL2NvbW1vbl8yNC5mOiBOZXcuCg== --------------010803080100060503000205 Content-Type: text/x-patch; name="pr67758_v2.diff" Content-Transfer-Encoding: 8bit Content-Disposition: attachment; filename="pr67758_v2.diff" Content-length: 933 Index: match.c =================================================================== --- match.c (révision 228170) +++ match.c (copie de travail) @@ -4330,10 +4330,6 @@ gfc_match_common (void) if (m == MATCH_NO) goto syntax; - /* Store a ref to the common block for error checking. */ - sym->common_block = t; - sym->common_block->refs++; - /* See if we know the current common block is bind(c), and if so, then see if we can check if the symbol is (which it'll need to be). This can happen if the bind(c) attr stmt was @@ -4379,6 +4375,10 @@ gfc_match_common (void) if (!gfc_add_in_common (&sym->attr, sym->name, NULL)) goto cleanup; + /* Store a ref to the common block for error checking. */ + sym->common_block = t; + sym->common_block->refs++; + if (tail != NULL) tail->common_next = sym; else --------------010803080100060503000205 Content-Type: text/x-fortran; name="common_24.f" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="common_24.f" Content-length: 302 c { dg-do compile } c PR fortran/67758 c c Check the absence of ICE after emitting the error message c c Contributed by Ilya Enkovich COMMON /FMCOM / X(80 000 000) CALL T(XX(A)) COMMON /FMCOM / XX(80 000 000) ! { dg-error "conflicts with COMMON" } END --------------010803080100060503000205--