From patchwork Thu Feb 14 23:23:42 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Malcolm X-Patchwork-Id: 1042482 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=gcc.gnu.org (client-ip=209.132.180.131; helo=sourceware.org; envelope-from=gcc-patches-return-496186-incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b="ARss06Xo"; dkim-atps=neutral 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 440rnN0bp6z9s3l for ; Fri, 15 Feb 2019 09:35:19 +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=R4EZMfbOswTKHw42N7ZDEof8h9p0jNdcCRxYOQjpIJa9/LC8lJFgz bClmRSPPrd+2Dj8CANFb4e3zm7cK+uqDRAa8CYMDTQpWo/v6c3wqZpo3oikV81sZ dynD3ou0/87MmhpnK9FOg5+V7gIepKP0nO9ujwk0f8Mtwrw8sNHvMY= 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=5FLrBwUaBSMAO0/hoqG+AdfXq3s=; b=ARss06XogwvJ1q/a/r6j INCClUjhKGSz0feYIHXNWlgDF9qGeivviAbgCsY8g4agFqsEqagU4iwNHN/ziVGT q+xnM4A+R/GGswIDxoIZY2DrXer49sPsoLExcrx471mEzhBmhLllqLgk5ZjerDf1 KRyUULq3mQlWoTSjdC9IQ3E= Received: (qmail 59940 invoked by alias); 14 Feb 2019 22:33:40 -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 59451 invoked by uid 89); 14 Feb 2019 22:33:28 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-25.9 required=5.0 tests=BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, KAM_LAZY_DOMAIN_SECURITY, SPF_HELO_PASS autolearn=ham version=3.3.2 spammy=toplevc, toplev.c, UD:toplev.c 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 ESMTP; Thu, 14 Feb 2019 22:33:27 +0000 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 15D35C0AAB27 for ; Thu, 14 Feb 2019 22:33:26 +0000 (UTC) Received: from c64.redhat.com (ovpn-112-37.phx2.redhat.com [10.3.112.37]) by smtp.corp.redhat.com (Postfix) with ESMTP id E4DBA5DEB2; Thu, 14 Feb 2019 22:33:24 +0000 (UTC) From: David Malcolm To: jakub@redhat.com, gcc-patches@gcc.gnu.org Cc: David Malcolm Subject: [PATCH 5/7] Fix memory leak in selftest::test_expansion_to_rtl Date: Thu, 14 Feb 2019 18:23:42 -0500 Message-Id: <1550186624-25444-6-git-send-email-dmalcolm@redhat.com> In-Reply-To: <1550186624-25444-1-git-send-email-dmalcolm@redhat.com> References: <1550186624-25444-1-git-send-email-dmalcolm@redhat.com> X-IsSubscribed: yes "make selftest-valgrind" shows: 187 bytes in 1 blocks are definitely lost in loss record 567 of 669 at 0x4A081D4: calloc (in /usr/lib64/valgrind/vgpreload_memcheck-amd64-linux.so) by 0x1F08260: xcalloc (xmalloc.c:162) by 0xB24F32: init_emit() (emit-rtl.c:5843) by 0xC10080: prepare_function_start() (function.c:4803) by 0xC10254: init_function_start(tree_node*) (function.c:4877) by 0x1CDF92A: selftest::test_expansion_to_rtl() (function-tests.c:595) by 0x1CE007C: selftest::function_tests_c_tests() (function-tests.c:676) by 0x1E010E7: selftest::run_tests() (selftest-run-tests.c:98) by 0x1062D1E: toplev::run_self_tests() (toplev.c:2225) by 0x1062F40: toplev::main(int, char**) (toplev.c:2303) by 0x1E5B90A: main (main.c:39) The allocation in question is: crtl->emit.regno_pointer_align = XCNEWVEC (unsigned char, crtl->emit.regno_pointer_align_length); This patch fixes this leak (and makes the output of "make selftest-valgrind" clean) by calling free_after_compilation at the end of the selftest in question. gcc/ChangeLog: Backport of r263339 from trunk. 2018-08-06 David Malcolm * function-tests.c (selftest::test_expansion_to_rtl): Call free_after_compilation. --- gcc/function-tests.c | 1 + 1 file changed, 1 insertion(+) diff --git a/gcc/function-tests.c b/gcc/function-tests.c index 1b5ebf3..196b3a3 100644 --- a/gcc/function-tests.c +++ b/gcc/function-tests.c @@ -661,6 +661,7 @@ test_expansion_to_rtl () ASSERT_STR_CONTAINS (dump, ") ;; function \"test_fn\"\n"); free (dump); + free_after_compilation (fun); } /* Run all of the selftests within this file. */