From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 24659 invoked by alias); 1 Mar 2017 23:32:55 -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 23869 invoked by uid 89); 1 Mar 2017 23:32:54 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-24.9 required=5.0 tests=AWL,BAYES_00,FREEMAIL_FROM,GIT_PATCH_0,GIT_PATCH_1,GIT_PATCH_2,GIT_PATCH_3,RCVD_IN_DNSWL_LOW,RCVD_IN_SORBS_SPAM,SPF_PASS autolearn=ham version=3.3.2 spammy=site X-HELO: mail-qk0-f175.google.com Received: from mail-qk0-f175.google.com (HELO mail-qk0-f175.google.com) (209.85.220.175) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Wed, 01 Mar 2017 23:32:53 +0000 Received: by mail-qk0-f175.google.com with SMTP id u188so97753695qkc.2 for ; Wed, 01 Mar 2017 15:32:53 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:subject:to:message-id:date:user-agent :mime-version; bh=Veo9LpbNig+7cgTMLsMLQAzlDubMxqfMWkiFzYhbV8c=; b=U875UqVwo5QEwo1LVIuzmibzMJ03B8bpKWmXUZTbTHLi6Ax94hlnfF9uZounagjiNl ub4vaHbkyFWG1DOCXZSbL4qq2iGYvrD2zcgwVHqzjhF2RsCj+tOuuBhMx1xAvL5mLdFp bXuwGvJzhHaH7KS+pgiIUJdPcmrP5QphyU3WjICjE716sVCsluSO28yAOhHxBKetSjp8 Eod4N6Ggzjd89jqhpkaDDQeGCE9juMIeO5MjcHQ6aQXWc8vNj7T/pcN/KEPw0unL19+w rmJ6C797ILurOkXFejsp2tYxr4qP3sp2guYTyI6MHdVbBQwZfbE/vRCvLJyp0LIGR3G+ CdIw== X-Gm-Message-State: AMke39lSQ88xSEDEMOpMvqdJE3RS0Zlaxxd5byAgtI9LjbwQCOiqaKFN+8HOEng0YfCrow== X-Received: by 10.55.111.199 with SMTP id k190mr12701908qkc.25.1488411172063; Wed, 01 Mar 2017 15:32:52 -0800 (PST) Received: from [192.168.0.3] (75-166-126-106.hlrn.qwest.net. [75.166.126.106]) by smtp.gmail.com with ESMTPSA id h6sm4181537qkd.56.2017.03.01.15.32.51 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 01 Mar 2017 15:32:51 -0800 (PST) From: Martin Sebor Subject: [PATCH] free MPFR caches in gimple-ssa-sprintf.c (PR 79699) To: Gcc Patch List , Joseph Myers Message-ID: <60d46e1a-686b-9c27-4b48-7b658f8507fa@gmail.com> Date: Wed, 01 Mar 2017 23:32:00 -0000 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.6.0 MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="------------8C7F2F3D6C7DCAF1399528E2" X-IsSubscribed: yes X-SW-Source: 2017-03/txt/msg00059.txt.bz2 This is a multi-part message in MIME format. --------------8C7F2F3D6C7DCAF1399528E2 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit Content-length: 875 The uses of MPFR in gimple-ssa-sprintf.c apparently cause the library to allocates some internal caches that it then leaks on program exit, causing Valgrind memory leak errors. The MPFR manual "strongly advises to [call mpfr_free_cache] before terminating a thread, or before exiting when using tools like 'valgrind' (to avoid memory leaks being reported)) so the attached patch does just that. It' seems like an obvious fix that could presumably be committed without a review or approval but I'd like to give others a chance to comment on the placement of the call and whether it should be guarded by ENABLE_VALGRIND_ANNOTATIONS. Joseph, since you commented on the bug, do you have a suggestion for a different site for it or a guard? The only other call to the function is in the Fortran FE and it's neither guarded nor does it appear to ever be called. Thanks Martin --------------8C7F2F3D6C7DCAF1399528E2 Content-Type: text/x-patch; name="gcc-79699.diff" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="gcc-79699.diff" Content-length: 592 PR tree-optimization/79699 - small memory leak in MPFR gcc/ChangeLog: PR tree-optimization/79699 * gimple-ssa-sprintf.c (pass_sprintf_length::execute): Free MPFR caches to avoid a memory leak on program exit. diff --git a/gcc/gimple-ssa-sprintf.c b/gcc/gimple-ssa-sprintf.c index 7688439..0c00fa0 100644 --- a/gcc/gimple-ssa-sprintf.c +++ b/gcc/gimple-ssa-sprintf.c @@ -3612,6 +3612,8 @@ pass_sprintf_length::execute (function *fun) /* Clean up object size info. */ fini_object_sizes (); + /* Clean up MPFR caches (see bug 79699). */ + mpfr_free_cache (); return 0; } --------------8C7F2F3D6C7DCAF1399528E2--