From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga14.intel.com (mga14.intel.com [192.55.52.115]) by dpdk.org (Postfix) with ESMTP id 75991E72 for ; Mon, 21 Sep 2015 11:01:03 +0200 (CEST) Received: from fmsmga003.fm.intel.com ([10.253.24.29]) by fmsmga103.fm.intel.com with ESMTP; 21 Sep 2015 02:01:02 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.17,567,1437462000"; d="scan'208";a="565598978" Received: from shvmail01.sh.intel.com ([10.239.29.42]) by FMSMGA003.fm.intel.com with ESMTP; 21 Sep 2015 02:00:56 -0700 Received: from shecgisg004.sh.intel.com (shecgisg004.sh.intel.com [10.239.29.89]) by shvmail01.sh.intel.com with ESMTP id t8L90qd8023137; Mon, 21 Sep 2015 17:00:52 +0800 Received: from shecgisg004.sh.intel.com (localhost [127.0.0.1]) by shecgisg004.sh.intel.com (8.13.6/8.13.6/SuSE Linux 0.8) with ESMTP id t8L90nMg004129; Mon, 21 Sep 2015 17:00:52 +0800 Received: (from zhetao@localhost) by shecgisg004.sh.intel.com (8.13.6/8.13.6/Submit) id t8L90nUO004125; Mon, 21 Sep 2015 17:00:49 +0800 From: Zhe Tao To: dev@dpdk.org Date: Mon, 21 Sep 2015 17:00:47 +0800 Message-Id: <1442826047-4093-1-git-send-email-zhe.tao@intel.com> X-Mailer: git-send-email 1.7.4.1 Subject: [dpdk-dev] [PATCH] eal: change to prevent memory leak in eal debug X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: patches and discussions about DPDK List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 21 Sep 2015 09:01:03 -0000 Free the memory allocated by the backtrace_symbols to prevent the memory leak Signed-off-by: Zhe Tao --- lib/librte_eal/bsdapp/eal/eal_debug.c | 6 ++++++ lib/librte_eal/linuxapp/eal/eal_debug.c | 6 ++++++ 2 files changed, 12 insertions(+) diff --git a/lib/librte_eal/bsdapp/eal/eal_debug.c b/lib/librte_eal/bsdapp/eal/eal_debug.c index 44fc4f3..82d1c81 100644 --- a/lib/librte_eal/bsdapp/eal/eal_debug.c +++ b/lib/librte_eal/bsdapp/eal/eal_debug.c @@ -53,11 +53,17 @@ void rte_dump_stack(void) size = backtrace(func, BACKTRACE_SIZE); symb = backtrace_symbols(func, size); + + if (NULL == symb) + return; + while (size > 0) { rte_log(RTE_LOG_ERR, RTE_LOGTYPE_EAL, "%d: [%s]\n", size, symb[size - 1]); size --; } + + free(symb); } /* not implemented in this environment */ diff --git a/lib/librte_eal/linuxapp/eal/eal_debug.c b/lib/librte_eal/linuxapp/eal/eal_debug.c index 44fc4f3..82d1c81 100644 --- a/lib/librte_eal/linuxapp/eal/eal_debug.c +++ b/lib/librte_eal/linuxapp/eal/eal_debug.c @@ -53,11 +53,17 @@ void rte_dump_stack(void) size = backtrace(func, BACKTRACE_SIZE); symb = backtrace_symbols(func, size); + + if (NULL == symb) + return; + while (size > 0) { rte_log(RTE_LOG_ERR, RTE_LOGTYPE_EAL, "%d: [%s]\n", size, symb[size - 1]); size --; } + + free(symb); } /* not implemented in this environment */ -- 1.9.3