From patchwork Fri Feb 24 20:38:25 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Harald Anlauf X-Patchwork-Id: 61447 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:5915:0:0:0:0:0 with SMTP id v21csp1133965wrd; Fri, 24 Feb 2023 12:39:13 -0800 (PST) X-Google-Smtp-Source: AK7set9xyiQmF0MgaDpHU6ZnIm16nq9KLOKFqx+ZVn67gFwO96r2hVNiALAtfUjEFhKw9/1296a1 X-Received: by 2002:a17:906:58c6:b0:8ea:825:a5db with SMTP id e6-20020a17090658c600b008ea0825a5dbmr12762214ejs.76.1677271152739; Fri, 24 Feb 2023 12:39:12 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1677271152; cv=none; d=google.com; s=arc-20160816; b=Js01eVXeszLtS+X5yk/Lwk59mYMmYFC12KsLwSNnsHydWZ8nxjrmiFw6YgtX9BPv6L J0nO658LaEy4DUysMznbRxYALab1lfywHpc7Nn+2GzzYrCic92XMLcfmFd83+vFP7lAw uge+ORzSDy7jxQ5vuiV5BA+kDxTuRvSaOoAykpAIDrBK+XTzAyLk4EEthGJUG5LurLeX JKVd69m8blHQyEbk34Fm0IhsLx55JY+X7Zl3XAkiNegKKqMyf1JdvG7eZ8+W25zA8aBh wMRfrTVQRpkFmKSg3xT34x6oyxJZrF01w3yvggpFVfzDv+3S5dIBdfbMmDZgQ3I3DnOx ijkw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:reply-to:from:list-subscribe:list-help:list-post :list-archive:list-unsubscribe:list-id:precedence:ui-outboundreport :sensitivity:importance:date:subject:to:message-id:mime-version :dmarc-filter:delivered-to:dkim-signature:dkim-filter; bh=6UJAoUmFRE63ZPvInD+0MoeKrBsgdFSeZwUCyyBKBmE=; b=JQiIm8MLKyrCCzglrs09l+nmGdxPxjTM3RPsZfcX3qdAn95mQvZRiUyxEv0aFWLMb6 1/fEsN4OJrOQYsA3IvAyjnIUBNCJTl9w4dgHeobOAF5MKE8/1s/OUM60tQdT5GZiNcNQ 396s76oZKsWmaDS/+smJZdoZ4G5R4JUW2a/Kdn+yVElECi90KvmGRba1vLsVymNKgFa5 p9TJ3t5FWywHkq3Xac9TDjJ6jL2mxJk17r+wCTKCrUheJzuD2PvoD97AEABhhi0+o3JQ Nk35pQBtgwJ2ZFvdSl2v4lxUNHQzWPrF6C6b/7FBQBDdFoEqFimgJ8tP5B+1ETLcgwSa ySDA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=MTxVWvRe; spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=gnu.org Received: from sourceware.org (server2.sourceware.org. [8.43.85.97]) by mx.google.com with ESMTPS id n12-20020a17090673cc00b008b20e95d474si28985621ejl.51.2023.02.24.12.39.12 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 24 Feb 2023 12:39:12 -0800 (PST) Received-SPF: pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 as permitted sender) client-ip=8.43.85.97; Authentication-Results: mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=MTxVWvRe; spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=gnu.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id C41F538515F4 for ; Fri, 24 Feb 2023 20:39:11 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org C41F538515F4 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1677271151; bh=6UJAoUmFRE63ZPvInD+0MoeKrBsgdFSeZwUCyyBKBmE=; h=To:Subject:Date:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:From; b=MTxVWvReCvQog5jw94QnIGJ8FepP7sgL9AoFZ0MyDLph05gAPqp3AMKXgj9jBcWKf rNGdxSxcCTuBLoTrz20Ud6inyxYUbY83s4qsTVPMS0nU1HMtKk+YFzDHfK4myB28jZ Qdm8IfvBW8wyhKyf1fJ5oCF6VlxFpf+ZFgxbOUwY= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mout.gmx.net (mout.gmx.net [212.227.15.18]) by sourceware.org (Postfix) with ESMTPS id A487C3857C45; Fri, 24 Feb 2023 20:38:26 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org A487C3857C45 X-UI-Sender-Class: 724b4f7f-cbec-4199-ad4e-598c01a50d3a Received: from [93.207.80.111] ([93.207.80.111]) by web-mail.gmx.net (3c-app-gmx-bs39.server.lan [172.19.170.91]) (via HTTP); Fri, 24 Feb 2023 21:38:25 +0100 MIME-Version: 1.0 Message-ID: To: fortran , gcc-patches Subject: [PATCH, committed] Fortran: frontend passes do_subscript leaks gmp memory [PR108924] Date: Fri, 24 Feb 2023 21:38:25 +0100 Importance: normal Sensitivity: Normal X-Priority: 3 X-Provags-ID: V03:K1:cJRSemLxQvJgl38MB//c4GxUzENCLr/BcjdhmoONDzDJ9546SZT0wACXIo4RmWBWTiA5Q FCSdi13Uc11IiDTx1oE0anveVIJeE9XdUnH4oqPbKgEeYo9kW+YsAmSBlHVLhD/THjHPz2IuH1HB W4mmATjF4nuQNYRe+1yP5str9DBWz0I8OkqsBThdsLg1QG/53KJW+mWApVEx0kQm/JGszUGMFr24 XsyzxPFVaOTfEXoqpy6xsT/juAjmGLVPeBpWOechywq20y0A9gT7wLeNvA+2NxXWkQ9hL5r5oHg+ Ls= UI-OutboundReport: notjunk:1;M01:P0:R+vl3+ZDcd0=;26Ef0hMkIpkPSurkhL4PhiRtM27 yGPqNlQiJNxJfzeqkrmSrquHdQaJh08zXtTQegH0lNpd/7TYijViQdPQ4bpGGKbV1JhTXuI1u ZKtzrOsMfyaAFkYpm+eaZbSexprUuX6EheDzOuv8IuZ997EQ+XMUpw8CkKhBCXpjtpWuyX510 keMzlFUjksYIkIAj2g5tGctJ44YvBvdiXjdh7Lx0SrKs9EEmbnLP8u2ZxjFhJ8aGByTwB8Rw3 zWqOC7wLmnr1F8vrDxAbNOM6HY7Rv5QpbGbKflUUOag6j0Lfl0qmB23+dNWzjmBnik31fEb+X ECV9XDlM88XBNHuOC4gWD3KgKJNrAWzRDuHo1dQr+aAIT+Vv71SAorg/T4gSg723ff/kJpsx3 ys9ElFF94nSLPCq4szgr6ncc6Hd8f0VgTvJqOjK9rDUTTCuQz4540DaaVLXfVYptikfCgX4Tp pbWyDJrprjn9Xqkn3ZxZV3MELsL6io0j5zEXehoUkiNNDruM0m72+C2preIz+SwGVROKdzAzO NN4msyPNmyCwwCIOtDCTmmrr78tX20YjAZn/ndKpIn6uA8zBfP3y48Zfu1HonbNltaZQxyG+L YmMo+5M+Lin1297vXnEHeFBoBDJnT4VWBK/bgMINXiNvfGTmK+hmmfa8g8r8hLf12Dg26E/HX l6h532J1E6mTLkJjW1epeNXRrNG+ekwhKaeoQd9ubH/uSri7BwKc5QGLamYBkZ9LCzyKv2+fx bcmixqGjT1FXHEOhPgAyCj1CTZPNJWRp1FWjglBjsETICp71+0Xj9+XlRbKQgl46gq0NIsSkA YxJOR+43QLjT4wJJyUpUdGrQ== X-Spam-Status: No, score=-11.0 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, FREEMAIL_FROM, GIT_PATCH_0, RCVD_IN_BARRACUDACENTRAL, RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H2, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Harald Anlauf via Gcc-patches From: Harald Anlauf Reply-To: Harald Anlauf Errors-To: gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org Sender: "Gcc-patches" X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1758746276273546544?= X-GMAIL-MSGID: =?utf-8?q?1758746276273546544?= Dear all, as reported by Richard - although without a testcase - we leak gmp memory in do_subscript(). The attached patch was derived by inspection of the code pointed at by valgrind and regtested on x86_64-pc-linux-gnu. Committed as obvious as commit r13-6336-g45f406c4f62e516b58dcda20b5a7aa43ff0aa0f3 Author: Harald Anlauf Date: Fri Feb 24 19:56:32 2023 +0100 Thanks, Harald From 45f406c4f62e516b58dcda20b5a7aa43ff0aa0f3 Mon Sep 17 00:00:00 2001 From: Harald Anlauf Date: Fri, 24 Feb 2023 19:56:32 +0100 Subject: [PATCH] Fortran: frontend passes do_subscript leaks gmp memory [PR108924] gcc/fortran/ChangeLog: PR fortran/108924 * frontend-passes.cc (do_subscript): Clear used gmp variable. --- gcc/fortran/frontend-passes.cc | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/gcc/fortran/frontend-passes.cc b/gcc/fortran/frontend-passes.cc index 02fcb41dbc4..90428982023 100644 --- a/gcc/fortran/frontend-passes.cc +++ b/gcc/fortran/frontend-passes.cc @@ -2883,7 +2883,10 @@ do_subscript (gfc_expr **e) have_do_end = false; if (!have_do_start && !have_do_end) - return 0; + { + mpz_clear (do_step); + return 0; + } /* No warning inside a zero-trip loop. */ if (have_do_start && have_do_end) -- 2.35.3