From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 48001 invoked by alias); 1 Oct 2015 00:07:44 -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 47974 invoked by uid 89); 1 Oct 2015 00:07:43 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=0.3 required=5.0 tests=AWL,BAYES_50,KAM_ASCII_DIVIDERS,KAM_LAZY_DOMAIN_SECURITY,T_RP_MATCHES_RCVD autolearn=no version=3.3.2 X-Spam-User: qpsmtpd, 2 recipients X-HELO: troutmask.apl.washington.edu Received: from troutmask.apl.washington.edu (HELO troutmask.apl.washington.edu) (128.95.76.21) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES256-GCM-SHA384 encrypted) ESMTPS; Thu, 01 Oct 2015 00:07:42 +0000 Received: from troutmask.apl.washington.edu (localhost [127.0.0.1]) by troutmask.apl.washington.edu (8.15.2/8.15.2) with ESMTPS id t9107eWX073697 (version=TLSv1.2 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO); Wed, 30 Sep 2015 17:07:40 -0700 (PDT) (envelope-from sgk@troutmask.apl.washington.edu) Received: (from sgk@localhost) by troutmask.apl.washington.edu (8.15.2/8.15.2/Submit) id t9107eXT073696; Wed, 30 Sep 2015 17:07:40 -0700 (PDT) (envelope-from sgk) Date: Thu, 01 Oct 2015 00:07:00 -0000 From: Steve Kargl To: fortran@gcc.gnu.org, gcc-patches@gcc.gnu.org Subject: Re: [PATCH] fortran/67758 -- Prevent ICE caused by misplaced COMMON Message-ID: <20151001000740.GC73614@troutmask.apl.washington.edu> References: <20151001000630.GB73614@troutmask.apl.washington.edu> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="mojUlQ0s9EVzWg2t" Content-Disposition: inline In-Reply-To: <20151001000630.GB73614@troutmask.apl.washington.edu> User-Agent: Mutt/1.5.24 (2015-08-30) X-SW-Source: 2015-10/txt/msg00002.txt.bz2 --mojUlQ0s9EVzWg2t Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-length: 553 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. > > 2015-09-30 Steven G. Kargl > > * symbol.c (gfc_restore_last_undo_checkpoint): Prevent ICE during > cleanup of a misplaced COMMON. > > 2015-09-30 Steven G. Kargl > > * gfortran.dg/pr67758.f: New test. > Now with the patch attached! -- Steve --mojUlQ0s9EVzWg2t Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="pr67758.diff" Content-length: 1022 Index: fortran/symbol.c =================================================================== --- fortran/symbol.c (revision 228306) +++ fortran/symbol.c (working copy) @@ -3211,6 +3211,11 @@ gfc_restore_last_undo_checkpoint (void) while (csym != p) { + if (!csym) + { + gfc_error ("Unexpected COMMON at %C"); + goto error; + } cparent = csym; csym = csym->common_next; } @@ -3237,6 +3242,8 @@ gfc_restore_last_undo_checkpoint (void) restore_old_symbol (p); } +error: + latest_undo_chgset->syms.truncate (0); latest_undo_chgset->tbps.truncate (0); Index: testsuite/gfortran.dg/pr67758.f =================================================================== --- testsuite/gfortran.dg/pr67758.f (revision 0) +++ testsuite/gfortran.dg/pr67758.f (working copy) @@ -0,0 +1,6 @@ +c { dg-do compile } +c PR fortran/67758 + COMMON /FMCOM / X(80 000 000) + CALL T(XX(A)) + COMMON /FMCOM / XX(80 000 000) ! { dg-error "Unexpected COMMON" } + END --mojUlQ0s9EVzWg2t--