From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 78560 invoked by alias); 24 Jun 2015 20:21:23 -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 78421 invoked by uid 89); 24 Jun 2015 20:21:22 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-0.8 required=5.0 tests=AWL,BAYES_50,KAM_LAZY_DOMAIN_SECURITY,RP_MATCHES_RCVD autolearn=ham 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; Wed, 24 Jun 2015 20:21:21 +0000 Received: from troutmask.apl.washington.edu (localhost [127.0.0.1]) by troutmask.apl.washington.edu (8.14.9/8.14.9) with ESMTP id t5OKLHek060524 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO); Wed, 24 Jun 2015 13:21:17 -0700 (PDT) (envelope-from sgk@troutmask.apl.washington.edu) Received: (from sgk@localhost) by troutmask.apl.washington.edu (8.14.9/8.14.9/Submit) id t5OKLHm6060523; Wed, 24 Jun 2015 13:21:17 -0700 (PDT) (envelope-from sgk) Date: Wed, 24 Jun 2015 20:30:00 -0000 From: Steve Kargl To: Manuel =?iso-8859-1?B?TPNwZXotSWLh8WV6?= Cc: "fortran@gcc.gnu.org List" , Gcc Patch List Subject: Re: [PR fortran/66528] unbalanced IF/ENDIF with -fmax-errors=1 causes invalid free Message-ID: <20150624202117.GA60485@troutmask.apl.washington.edu> References: MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: User-Agent: Mutt/1.5.23 (2014-03-12) X-SW-Source: 2015-06/txt/msg01742.txt.bz2 On Wed, Jun 24, 2015 at 08:36:45PM +0200, Manuel López-Ibáñez wrote: > The problem is that diagnostic_action_after_output tries to delete the > active pretty-printer which tries to delete its output_buffer, which > is normally dynamically allocated via placement-new, but the > output_buffer used by the error_buffer of Fortran is statically > allocated. Being statically allocated simplifies a lot pushing/poping > several instances of error_buffer. > > The solution I found is to reset the active output_buffer back to the > default one before calling diagnostic_action_after_output. This is a > bit ugly, because this function does use the output_buffer, however, > at the point that Fortran calls it, both are in an equivalent state, > thus there is no visible difference. > > > Bootstrapped and regression tested on x86_64-linux-gnu. > > 2015-06-24 Manuel López-Ibáñez > > PR fortran/66528 > * gfortran.dg/maxerrors.f90: New test. > > gcc/fortran/ChangeLog: > > 2015-06-24 Manuel López-Ibáñez > > PR fortran/66528 > * error.c (gfc_warning_check): Restore the default output_buffer > before calling diagnostic_action_after_output. > (gfc_error_check): Likewise. > (gfc_diagnostics_init): Add comment. Patch looks ok to me. -- Steve