From patchwork Wed Nov 19 10:46:02 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Malcolm X-Patchwork-Id: 412327 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id E32EC14012B for ; Wed, 19 Nov 2014 21:39:47 +1100 (AEDT) DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:from :to:cc:subject:date:message-id:in-reply-to:references; q=dns; s= default; b=T7JvZFltyqTS3bZR3bHhqy7B8th2a37JBvUnjj1LEJmTGRSJ+llqN AmHVIPP1niOA1w/Bv6RM2RMHMffrPHoxbmFDdzLSa4WGWRHbhJQdG/9/JRNQA7rs XWltuBxo9tT7hD+txHkdZXRb5ZgUwuiKuFSi/XOPzKb6cjp46SCD6o= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:from :to:cc:subject:date:message-id:in-reply-to:references; s= default; bh=fJ9dpIUarwZSP23zg8V6o228fzk=; b=feT3/clu2/bDhE3GDAUk xrG6NjjJBdvgNIta9UYo9RgudAi03F5Lkuc21PL/IkYMuDFo7pdMhNGgRYoL/EKl xk/d6KLKuh//nl/XT50K5/7oMYQsbSKFyXgFS/TGgE0VIY+Sh/ZOoNRrgphYTpLn fHjCdVc4TkVTZ2A9utsa8s0= Received: (qmail 32293 invoked by alias); 19 Nov 2014 10:39:23 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Delivered-To: mailing list gcc-patches@gcc.gnu.org Received: (qmail 32195 invoked by uid 89); 19 Nov 2014 10:39:22 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.0 required=5.0 tests=AWL, BAYES_00, SPF_HELO_PASS, SPF_PASS, T_RP_MATCHES_RCVD autolearn=ham version=3.3.2 X-Spam-User: qpsmtpd, 2 recipients X-HELO: mx1.redhat.com Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES256-GCM-SHA384 encrypted) ESMTPS; Wed, 19 Nov 2014 10:39:20 +0000 Received: from int-mx13.intmail.prod.int.phx2.redhat.com (int-mx13.intmail.prod.int.phx2.redhat.com [10.5.11.26]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id sAJAdJH9016599 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL); Wed, 19 Nov 2014 05:39:19 -0500 Received: from c64.redhat.com (vpn-238-24.phx2.redhat.com [10.3.238.24]) by int-mx13.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id sAJAdGYC026088; Wed, 19 Nov 2014 05:39:18 -0500 From: David Malcolm To: gcc-patches@gcc.gnu.org, jit@gcc.gnu.org Cc: David Malcolm Subject: [PATCH 02/21] PR jit/63854: Fix memory leak of reginfo.c: valid_mode_changes_obstack Date: Wed, 19 Nov 2014 05:46:02 -0500 Message-Id: <1416393981-39626-3-git-send-email-dmalcolm@redhat.com> In-Reply-To: <1416393981-39626-1-git-send-email-dmalcolm@redhat.com> References: <1416393981-39626-1-git-send-email-dmalcolm@redhat.com> X-IsSubscribed: yes Valgrind shows this fixes ~4 KB of leak per iteration (on x86_64) by plugging this leak allocated at reginfo.c:1327: gcc_obstack_init (&valid_mode_changes_obstack); ==57820== 16,256 bytes in 4 blocks are definitely lost in loss record 906 of 917 ==57820== at 0x4A0645D: malloc (in /usr/lib64/valgrind/vgpreload_memcheck-amd64-linux.so) ==57820== by 0x59A6747: xmalloc (xmalloc.c:147) ==57820== by 0x30958842DB: _obstack_begin (obstack.c:184) ==57820== by 0x51C1EC1: init_subregs_of_mode() (reginfo.c:1327) ==57820== by 0x50D2A38: init_costs() (ira-costs.c:2181) ==57820== by 0x50D74A8: ira_costs() (ira-costs.c:2211) ==57820== by 0x50D1326: ira_build() (ira-build.c:3459) ==57820== by 0x50C909C: (anonymous namespace)::pass_ira::execute(function*) (ira.c:5227) ==57820== by 0x51884F7: execute_one_pass(opt_pass*) (passes.c:2269) ==57820== by 0x5188B75: execute_pass_list_1(opt_pass*) (passes.c:2321) ==57820== by 0x5188B87: execute_pass_list_1(opt_pass*) (passes.c:2322) ==57820== by 0x5188BC8: execute_pass_list(function*, opt_pass*) (passes.c:2332) gcc/ChangeLog: PR jit/63854 * reginfo.c (finish_subregs_of_mode): Replace obstack_finish with obstack_free when cleaning up valid_mode_changes_obstack. --- gcc/reginfo.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gcc/reginfo.c b/gcc/reginfo.c index efe23cd..c2daf22 100644 --- a/gcc/reginfo.c +++ b/gcc/reginfo.c @@ -1343,7 +1343,7 @@ void finish_subregs_of_mode (void) { XDELETEVEC (valid_mode_changes); - obstack_finish (&valid_mode_changes_obstack); + obstack_free (&valid_mode_changes_obstack, NULL); } /* Free all data attached to the structure. This isn't a destructor because