From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-ed1-x52b.google.com (mail-ed1-x52b.google.com [IPv6:2a00:1450:4864:20::52b]) by sourceware.org (Postfix) with ESMTPS id E31B83858D3C; Mon, 8 May 2023 06:00:09 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org E31B83858D3C Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=gmail.com Received: by mail-ed1-x52b.google.com with SMTP id 4fb4d7f45d1cf-50bc394919cso6198614a12.2; Sun, 07 May 2023 23:00:09 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1683525608; x=1686117608; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:subject:cc:to:from:date:from:to:cc:subject:date :message-id:reply-to; bh=oP1TAtXE5EUweg2BgAsUBFf6ejokYB1jqQ2Fs0MdSUQ=; b=PpLm0TBO0Y+z0nVGuLmLgnyyt2hDpYxWb27xYWgJu1mS5JUJP2Edb3KGLTea5nbvm4 GER2rx1fEIWNV/BoUvt0e3H3J1vMDwdTrXjkvY/S3nzuqtIZqJFrvKE44CXK5Z449+lR RPwWPDFAeYhkH4p5HdHcYvlDqIrkFqTI5HvuNynM9Wk3DmbE+gj0kLfJsgwxRoZ+Uioi yJ9YOFOKt332Nw71sQBW317l58mw+hHwds9YEG2M81FIzRmxBiOUu3YlGgdgCTp3lsjZ Vjqn8tzr12p07gAAriPrwTHOhimLIar54amkedvgCFjdo21UV9ljLKh9EccccleseKZn H42g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1683525608; x=1686117608; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:subject:cc:to:from:date:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=oP1TAtXE5EUweg2BgAsUBFf6ejokYB1jqQ2Fs0MdSUQ=; b=QRR+WjnKMjATwoKlLbXm7sV2gzyidZ75QUS3Qfv+G3igl6rwXJQtX+//NbKl5DqmLk R5KfhEn4Ch2X6++i1qRnX4Dn9fJh8nIIMTuyRassydChKpIstFVnc0RN83vQMJzRWhhN 6xF8944M556WIp7BYvTPda1ZsbSGTCUpATuJf5e495mVRZJEfQF38wXvdMdKyyf+YPrh HxYzCIRewNMHCc3dNajFS8dWXnNcJUPjydg/WE6orR6FIIzCKA0m3vTUBVxevmaFYo4k c3fqco4+ggAAAYNhneP4/JOnlTEfAuzj0t99nPr/jKO15LHpCLTY9CQR2XgAv37mJhcO AB3g== X-Gm-Message-State: AC+VfDzXQaBWuBVZFee32uM/FBzgZwW7WWAR2AudkAZKf+j/oUXZEY3V wOXpogV32ohdkjCRQQsUYS4wk9cA3Ec= X-Google-Smtp-Source: ACHHUZ7IPV/I3brJOEhlhi3vf7LIQMDjJqnfDOp8xKzZFvMxkeT8l9Y/n5w/WBi4yNAdBqbUL+nVOg== X-Received: by 2002:aa7:d593:0:b0:50b:cd19:7545 with SMTP id r19-20020aa7d593000000b0050bcd197545mr6191888edq.33.1683525608120; Sun, 07 May 2023 23:00:08 -0700 (PDT) Received: from nbbrfq (80-110-214-113.static.upcbusiness.at. [80.110.214.113]) by smtp.gmail.com with ESMTPSA id s16-20020aa7d790000000b0050a276e7ba8sm5684973edq.36.2023.05.07.23.00.07 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 07 May 2023 23:00:07 -0700 (PDT) Date: Mon, 8 May 2023 08:00:03 +0200 From: Bernhard Reutner-Fischer To: Steve Kargl Cc: Bernhard Reutner-Fischer via Fortran , gcc-patches@gcc.gnu.org, Harald Anlauf , Bernhard Reutner-Fischer Subject: Re: ping Re: [PATCH 3/3] Fortran: Fix mpz and mpfr memory leaks Message-ID: <20230508080003.79d0e408@nbbrfq> In-Reply-To: References: <20230402150515.40826-4-rep.dot.nop@gmail.com> <57162b6a-95e0-35c6-386a-3687908fce05@gmx.de> <20230417214750.539e74dc@nbbrfq> MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-9.6 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM,GIT_PATCH_0,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS,TXREP,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: On Mon, 17 Apr 2023 15:18:27 -0700 Steve Kargl wrote: > On Mon, Apr 17, 2023 at 09:47:50PM +0200, Bernhard Reutner-Fischer via Fortran wrote: > > On Mon, 03 Apr 2023 23:42:06 +0200 > > Bernhard Reutner-Fischer wrote: > > > > > On 3 April 2023 21:50:49 CEST, Harald Anlauf wrote: > > > >Hi Bernhard, > > > > > > > >there is neither context nor a related PR with a testcase showing > > > >that this patch fixes issues seen there. > > > > > > Yes, i forgot to mention the PR: > > > > > > PR fortran/68800 > > > > > > I did not construct individual test cases but it should be obvious that we should not leak these. > > > > > > > > > > >On 4/2/23 17:05, Bernhard Reutner-Fischer via Gcc-patches wrote: > > > >> From: Bernhard Reutner-Fischer > > > >> > > > >> Cc: fortran@gcc.gnu.org > > > >> > > > >> gcc/fortran/ChangeLog: > > > >> > > > >> * array.cc (gfc_ref_dimen_size): Free mpz memory before ICEing. > > > >> * expr.cc (find_array_section): Fix mpz memory leak. > > > >> * simplify.cc (gfc_simplify_reshape): Fix mpz memory leaks in > > > >> error paths. > > > >> (gfc_simplify_set_exponent): Fix mpfr memory leak. > > > >> --- > > > >> gcc/fortran/array.cc | 3 +++ > > > >> gcc/fortran/expr.cc | 8 ++++---- > > > >> gcc/fortran/simplify.cc | 7 ++++++- > > > >> 3 files changed, 13 insertions(+), 5 deletions(-) > > > >> > > > >> diff --git a/gcc/fortran/array.cc b/gcc/fortran/array.cc > > > >> index be5eb8b6a0f..8b1e816a859 100644 > > > >> --- a/gcc/fortran/array.cc > > > >> +++ b/gcc/fortran/array.cc > > > >> @@ -2541,6 +2541,9 @@ gfc_ref_dimen_size (gfc_array_ref *ar, int dimen, mpz_t *result, mpz_t *end) > > > >> return t; > > > >> > > > >> default: > > > >> + mpz_clear (lower); > > > >> + mpz_clear (stride); > > > >> + mpz_clear (upper); > > > >> gfc_internal_error ("gfc_ref_dimen_size(): Bad dimen_type"); > > > >> } > > > > > > > > What is the point of clearing variables before issuing > > > > a gfc_internal_error? > > > > > > To make it obvious that we are aware that we allocated these. > > I must admit I agree with Harald on this portion > of the diff. What's the point? There is alot more > allocated than just those 3 mzp_t variables when the > internal error occurs. For example, gfortran does not > walk the namespaces and free those before the ICE. > I suppose silencing valgrind might be sufficient > reason for the clutter. So, ok. I've dropped this hunk and pushed the rest as r14-567-g2521390dd2f8e5 Harald fixed the leak of expr in gfc_simplify_set_exponent in the meantime. thanks,