From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mout.gmx.net (mout.gmx.net [212.227.17.20]) by sourceware.org (Postfix) with ESMTPS id 20F783858C2C; Wed, 3 Jan 2024 19:33:08 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 20F783858C2C Authentication-Results: sourceware.org; dmarc=pass (p=quarantine dis=none) header.from=gmx.de Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=gmx.de ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 20F783858C2C Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=212.227.17.20 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1704310390; cv=none; b=KZSh1nZ76uJBwkFcS+sEDkfRafazu4SVdRLINCeWDMm4xESZDiXPienpyOzWbnvYrWN1lAVc18ftWnsRKSZRPDhnPF16UFFUeFYipN5u36PDAhOZs1qx1Kz/+GYyqFxTTouf0UaWA3yhOFcU5wS8NjJQ81kW3OlFwBW7dvnuaw8= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1704310390; c=relaxed/simple; bh=WhET4Cb16nkijz0tTayIBRBAMy8yf0ryVeg396unAIk=; h=DKIM-Signature:MIME-Version:Message-ID:From:To:Subject:Date; b=HLJLBIau3dorrbWA5ZwrLDmygT0TmSW2fvL47LeGLQ5u1ImKgMWftWet/e2Sx4Q/9SgUB6mBgPEi4fYWLADS8XVEPvq7BpsHLcmnZpx4DVTY5NCyOazlcNNMxRWbxETHfK8FM8fcUEqlWkp6qDfs9IgXYiwD4YEXgxpSWs7v6r0= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gmx.de; s=s31663417; t=1704310386; x=1704915186; i=anlauf@gmx.de; bh=WhET4Cb16nkijz0tTayIBRBAMy8yf0ryVeg396unAIk=; h=X-UI-Sender-Class:From:To:Subject:Date; b=GtkrcbmXwHd8vqj2W+XXC+JVU6WbayWLTfV+bvuVL0J+tOsKko9+mFwMwkLyOmce qqsdCqZEtBUMNAii6Fy2D2TKOrpJyBC1f/g8eHCu5x5MntMtjZM2haG7eo1tv4KL7 +UVbtvE1VjUE+MivbbCOkU4sV5CEaEjgE02DTJynkmFrXsLKNLUnpBEj9qg4XzfkL X1vMTa2QKKqEKAoClFxrLPfo6QQ3dIKOGQwVJ9uzmETWSrbQC1dV9GfA5jRe9j5pq LTqDi/ePYTzDmQqK72JBfHar69cmxRPjK6lTtFP0TkLyv2HWbvBS05Zk1R3LwA76t kJe8xy0DzEyP3reitA== X-UI-Sender-Class: 724b4f7f-cbec-4199-ad4e-598c01a50d3a Received: from [79.232.150.103] ([79.232.150.103]) by web-mail.gmx.net (3c-app-gmx-bap46.server.lan [172.19.172.116]) (via HTTP); Wed, 3 Jan 2024 20:33:06 +0100 MIME-Version: 1.0 Message-ID: From: Harald Anlauf To: fortran , gcc-patches Subject: [PATCH, committed] Fortran: fix FE memleak Content-Type: multipart/mixed; boundary=rekceb-965908a0-c85c-4d0a-bc5c-029f5a65cdd1 Date: Wed, 3 Jan 2024 20:33:06 +0100 Importance: normal Sensitivity: Normal X-Priority: 3 X-Provags-ID: V03:K1:aR/q3w8LBe51cH4iolXk9qr2UOEjsycgvFDL5iR6lBKPrCms4mZjHW7+wZhTPMDX03vfS jEZxnQer56jAx1HnALww2RGpU5/+kOvXtARE4nRLt1R3xlEGNOAlbRITj1O8BRj4Xt+MN0fwiT/7 fLlHc2PTadHhXcdaeKe6yEOfSfHWn+g5kax00yNLPZXak0Zh/x+K7ORAo1VUybnOyeYW5DtOHiLC c3z7jk1F0XtaYAauak/DWsPwv/xgSTyY849xvZMhyJjuxodblqDdKpexL4hXO3fOee0SUnIER/TC GQ= UI-OutboundReport: notjunk:1;M01:P0:5D5QB//5mX8=;BKoYUrVS5uCNrQwHttE58BCxEKR qNcbvXJOEAKIkruR8YbE2No0qlsICJUZPBTDQj0iHHMFRNzaGO1oNJshFn70ui/wzXU8GCBQz 57cYZ31yS7tpERCZnyRxgMFfYuz41mzwPhVE3t++g+3XOh24wbkSoENNYw6JgzK2sPzA+QkD1 Lby065hcWU3w4mWWYPIhN9N0Vfj9qljZg8dG7Vq72+iTJiEkW0vEldflw/b2563t64HkuyNHd cFhoFaGeanCvz+1QhW/ETNx9FZmuDPBgL+AHR1XrppTwgdE/ruqqWexEKGF0MgeTHyyl75WyF UE37+BijTOv1jmLe8Nyw/AwNyMN3tyKXQZEFSShZ7KeUuJJhUeXUfxL1zS6/2e/KfPIdhtG7N mpHq5CdY9bHoZqgedwogsvNiqBgy/fB2AlaqfvL0o8iyw8SaLrCDZpRaQTRMPP0YodS79KIGr bP0koSjmFMuneBR69gkeY4tLKrUeZM4IHO+z9LevXf/woSXQjNVGhB+SyGBgpYBZeDVcEmzWZ evNvYVztxyjddlypXKIDm+B9uX9gai2EbwEdeud4kCEUcqRuLXv5cjzA1COHkTfSz3xD5kV0b of6XQ01p9E4BVrjVIIAq0aqwnVzXlICJk/8/VQdH9z3A63AMjuU9TODavNrMglN6aENPzW+jw fWOFzVxL+suXf6Aya+nYlxVJgW3/Qz+iksviTiNCOkkGVBByhG97/UzozbM4cQojtnq2AePW+ 0cd2TZdLNhZDUpe7eCy+2iqq0tOJdN50i2C3DmQm5T0UTFgxvFx21YhdTwUuqB0GH8hcIWZtG RE2/IILwP5xJtBK6RuKhpRsg== X-Spam-Status: No, score=-12.5 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM,GIT_PATCH_0,RCVD_IN_DNSWL_LOW,RCVD_IN_MSPIKE_H4,RCVD_IN_MSPIKE_WL,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: --rekceb-965908a0-c85c-4d0a-bc5c-029f5a65cdd1 Content-Type: text/plain; charset=UTF-8 Dear all, I've committed the attached, simple & obvious patch for a gmp memory leak in gfc_get_nodesc_array_type that shows up when running f951 under valgrind e.g. on testcase gfortran.dg/class_optional_2.f90, after regtesting on x86_64-pc-linux-gnu. (Note that this does not address the underlying issues of pr55978). Thanks, Harald --rekceb-965908a0-c85c-4d0a-bc5c-029f5a65cdd1 Content-Type: text/x-patch Content-Disposition: attachment; filename=0001-Fortran-fix-FE-memleak.patch Content-Transfer-Encoding: quoted-printable =46rom 93c96e3ad0024a397115aa17bf29c7efc6b535a1 Mon Sep 17 00:00:00 2001 From: Harald Anlauf Date: Wed, 3 Jan 2024 20:21:00 +0100 Subject: [PATCH] Fortran: fix FE memleak gcc/fortran/ChangeLog: * trans-types.cc (gfc_get_nodesc_array_type): Clear used gmp variables. =2D-- gcc/fortran/trans-types.cc | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/gcc/fortran/trans-types.cc b/gcc/fortran/trans-types.cc index e6db1c95450..676014e9b98 100644 =2D-- a/gcc/fortran/trans-types.cc +++ b/gcc/fortran/trans-types.cc @@ -1795,7 +1795,7 @@ gfc_get_nodesc_array_type (tree etype, gfc_array_spe= c * as, gfc_packed packed, TYPE_LANG_SPECIFIC (type) =3D TYPE_LANG_SPECIFIC (TREE_TYPE (type)); } - return type; + goto array_type_done; } if (known_stride) @@ -1814,10 +1814,6 @@ gfc_get_nodesc_array_type (tree etype, gfc_array_sp= ec * as, gfc_packed packed, layout_type (type); - mpz_clear (offset); - mpz_clear (stride); - mpz_clear (delta); - /* Represent packed arrays as multi-dimensional if they have rank > 1 and with proper bounds, instead of flat arrays. This makes for better debug info. */ @@ -1848,6 +1844,12 @@ gfc_get_nodesc_array_type (tree etype, gfc_array_sp= ec * as, gfc_packed packed, GFC_ARRAY_TYPE_P (type) =3D 1; TYPE_LANG_SPECIFIC (type) =3D TYPE_LANG_SPECIFIC (TREE_TYPE (type))= ; } + +array_type_done: + mpz_clear (offset); + mpz_clear (stride); + mpz_clear (delta); + return type; } =2D- 2.35.3 --rekceb-965908a0-c85c-4d0a-bc5c-029f5a65cdd1--