From patchwork Thu Feb 13 09:44:58 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Damijan Skvarc X-Patchwork-Id: 1237381 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=openvswitch.org (client-ip=140.211.166.137; helo=fraxinus.osuosl.org; envelope-from=ovs-dev-bounces@openvswitch.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20161025 header.b=f8RMjXEq; dkim-atps=neutral Received: from fraxinus.osuosl.org (smtp4.osuosl.org [140.211.166.137]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 48JBSj3N29z9s29 for ; Thu, 13 Feb 2020 20:45:08 +1100 (AEDT) Received: from localhost (localhost [127.0.0.1]) by fraxinus.osuosl.org (Postfix) with ESMTP id C9CAF85FB2; Thu, 13 Feb 2020 09:45:06 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from fraxinus.osuosl.org ([127.0.0.1]) by localhost (.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id TVoq-BuwVLDk; Thu, 13 Feb 2020 09:45:06 +0000 (UTC) Received: from lists.linuxfoundation.org (lf-lists.osuosl.org [140.211.9.56]) by fraxinus.osuosl.org (Postfix) with ESMTP id 3A7AF85F89; Thu, 13 Feb 2020 09:45:06 +0000 (UTC) Received: from lf-lists.osuosl.org (localhost [127.0.0.1]) by lists.linuxfoundation.org (Postfix) with ESMTP id 2D27DC08A4; Thu, 13 Feb 2020 09:45:06 +0000 (UTC) X-Original-To: dev@openvswitch.org Delivered-To: ovs-dev@lists.linuxfoundation.org Received: from fraxinus.osuosl.org (smtp4.osuosl.org [140.211.166.137]) by lists.linuxfoundation.org (Postfix) with ESMTP id 04C4DC0177 for ; Thu, 13 Feb 2020 09:45:05 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by fraxinus.osuosl.org (Postfix) with ESMTP id E810285F89 for ; Thu, 13 Feb 2020 09:45:04 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from fraxinus.osuosl.org ([127.0.0.1]) by localhost (.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 8Sv2nPtpJ4U7 for ; Thu, 13 Feb 2020 09:45:04 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.6 Received: from mail-wr1-f65.google.com (mail-wr1-f65.google.com [209.85.221.65]) by fraxinus.osuosl.org (Postfix) with ESMTPS id 2AA6385F94 for ; Thu, 13 Feb 2020 09:45:04 +0000 (UTC) Received: by mail-wr1-f65.google.com with SMTP id z3so5818227wru.3 for ; Thu, 13 Feb 2020 01:45:04 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id; bh=QV4yrILw6Uh3BHJHRVy/GuzF7z+RsMhymLjMxFp2CLQ=; b=f8RMjXEqaKpQGiVpXFOG2IMArlA+ZelBoMycjpA6nUHunGkbMOSF+K/3n/kDqJL8Kq cQAZcXqIXQNWCQQUfIMIlqI1dwhx4zX6qGcm1FxFRvriI3c9QcMeyEYsdM9+c2csri1e RNzRGkyvIjd4Bn6EYUWDzc1ijDRENqIWX5EGRgzSGLPhkic5u+5dA07k00XShf1xUuly 5IUi8r+SNL4moXYm+K/SoxwwiYvrmdeppj4b01nIokXVuaX4hj0zNJ8ueuD6E5kLSzAC eXnOXUxThMp/QiNkfk9x/z1TZzorWsQmECoDk9/bLqW329fjmjbra7yBUhEoLKz462jz Eqbw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=QV4yrILw6Uh3BHJHRVy/GuzF7z+RsMhymLjMxFp2CLQ=; b=Gqgp3Hfr+uMITnHsMCbokKWDz5h9JWDTKlDOsstPs5g3VRQ5eEl8EmRZGqUTapGDqy 8PVwifZr9rSfy1zcHJP4YJwPz1DT20YYGjMl7CruxOuD8ROyTBMf4HDI8gDhttQqugl1 1NGt5wDqw62t+CGjDA6u0aqoNM1lNB6xjt4Yz/lP+niSgnF4fEsLoQmeB8Jsly/Wyy/7 oQwDV9cqsXYJkrCCrlPLhcX4+rGts/X+5xpZSmFXE8U53J5STefGIn3EdzQL3E4yusir 47PtF6IoBi4uxucvVKlVFy3PiJcNcdbII+IvtcnyEymhw5TgUpubp7mNGxbHdXG0r8V+ wd8w== X-Gm-Message-State: APjAAAUrQK74LU5Hl7/GiGvUiepkfsXKFJq+sJMbfxrsSU3p76xwSibN dlN6MZxm7vsYfrSBKbDX1Idry24+ X-Google-Smtp-Source: APXvYqya4NnMaSMZBPId67THb80HFh/4n+o5Mqr8pidVNXlOhlhaXDNas2wSwR4y/pTet0J9NmaRDg== X-Received: by 2002:adf:e692:: with SMTP id r18mr20903472wrm.413.1581587102207; Thu, 13 Feb 2020 01:45:02 -0800 (PST) Received: from damijan-PC.i-tech.local (mail.i-tech.si. [89.212.78.105]) by smtp.gmail.com with ESMTPSA id x6sm2157192wmi.44.2020.02.13.01.45.01 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 13 Feb 2020 01:45:01 -0800 (PST) From: Damijan Skvarc To: dev@openvswitch.org Date: Thu, 13 Feb 2020 10:44:58 +0100 Message-Id: <1581587098-27905-1-git-send-email-damjan.skvarc@gmail.com> X-Mailer: git-send-email 2.7.4 Subject: [ovs-dev] [PATCH 1/1] test-ovn: fix memory leak X-BeenThere: ovs-dev@openvswitch.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: ovs-dev-bounces@openvswitch.org Sender: "dev" Many memory leaks were detected by valgrind while running "3-term numeric expression simplification" unit test. All of them are reported in a form similar to: ==25922== 57,071,464 bytes in 192,809 blocks are definitely lost in loss record 70 of 70 ==25922== at 0x4C2DB8F: malloc (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so) ==25922== by 0x468604: xmalloc (util.c:138) ==25922== by 0x5354B1: expr_create_boolean (expr.c:222) ==25922== by 0x5354B1: expr_fix_andor (expr.c:268) ==25922== by 0x536F0F: expr_simplify (expr.c:2108) ==25922== by 0x409C73: test_tree_shape_exhaustively (test-ovn.c:914) ==25922== by 0x40A83E: test_exhaustive (test-ovn.c:1140) ==25922== by 0x4110D3: ovs_cmdl_run_command__ (command-line.c:247) ==25922== by 0x407B01: test_ovn_main (test-ovn.c:1623) ==25922== by 0x407B01: ovstest_wrapper_test_ovn_main__ (test-ovn.c:1626) ==25922== by 0x4110D3: ovs_cmdl_run_command__ (command-line.c:247) ==25922== by 0x4066B9: main (ovstest.c:133) The problem was in test_tree_shape_exhaustively() function which overides pointer to temporary allocated expression without freeing it first. Signed-off-by: Damijan Skvarc --- tests/test-ovn.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/test-ovn.c b/tests/test-ovn.c index 8ef886d..c607a8f 100644 --- a/tests/test-ovn.c +++ b/tests/test-ovn.c @@ -913,7 +913,7 @@ test_tree_shape_exhaustively(struct expr *expr, struct shash *symtab, } else if (operation >= OP_SIMPLIFY) { modified = expr_simplify(expr_clone(expr)); modified = expr_evaluate_condition( - expr_clone(modified), tree_shape_is_chassis_resident_cb, NULL); + modified, tree_shape_is_chassis_resident_cb, NULL); ovs_assert(expr_honors_invariants(modified)); if (operation >= OP_NORMALIZE) {