From patchwork Fri Aug 3 01:14:23 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Malcolm X-Patchwork-Id: 953027 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-483077-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="NUCOB9QZ"; 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 41hXHj6K2dz9s2g for ; Fri, 3 Aug 2018 13:16:00 +1000 (AEST) 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; q=dns; s=default; b=C8M8pUSH0dln aHQdz5l3mjP2ukIyBnb8M0hUbm8mY9wF+cTP9KVljoKnTqBcyvkJPwLa/0lG7CAq gRs1ZePClbWVINPUc3kqhBvxB+b3qq8yJUSWGQUL7jRBFc7xEM53bw/FI6oZL8eo RghFc7LOc+E2Af+nucB6Ut7YE60ZK90= 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; s=default; bh=40q3ML9XpOmTBYD706 BHLLXts7Y=; b=NUCOB9QZpKfs+wlmwO35SJJtExgEORkoPlc+GKvQ6HgmPiEYZu jt3lEC3kQaplPUfj/wQouJo9fjJrUSQoZyKFgewckL8hxBB2/mBO3rs6MEQ0f29w G3ZJzKaFxFubAqbRudaaZ15WRbiNqkP9loiWUbKOJZi3f0cRi9jHcr7I0= Received: (qmail 55820 invoked by alias); 3 Aug 2018 00:29:18 -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 55808 invoked by uid 89); 3 Aug 2018 00:29:17 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-26.9 required=5.0 tests=BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, SPF_HELO_PASS autolearn=ham version=3.3.2 spammy= 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; Fri, 03 Aug 2018 00:29:16 +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 3069D81DE2 for ; Fri, 3 Aug 2018 00:29:15 +0000 (UTC) Received: from c64.redhat.com (ovpn-112-32.phx2.redhat.com [10.3.112.32]) by smtp.corp.redhat.com (Postfix) with ESMTP id 553D27C755; Fri, 3 Aug 2018 00:29:14 +0000 (UTC) From: David Malcolm To: gcc-patches@gcc.gnu.org Cc: David Malcolm Subject: [PATCH] Fix memory leak in selftest::test_expansion_to_rtl Date: Thu, 2 Aug 2018 21:14:23 -0400 Message-Id: <1533258863-46623-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. Successfully bootstrapped & regrtested on x86_64-pc-linux-gnu. OK for trunk? gcc/ChangeLog: * 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. */