From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from demumfd002.nsn-inter.net (demumfd002.nsn-inter.net [93.183.12.31]) by dpdk.org (Postfix) with ESMTP id F01A45937 for ; Tue, 4 Aug 2015 11:04:20 +0200 (CEST) Received: from demuprx017.emea.nsn-intra.net ([10.150.129.56]) by demumfd002.nsn-inter.net (8.15.1/8.15.1) with ESMTPS id t7494KdJ004531 (version=TLSv1 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Tue, 4 Aug 2015 09:04:20 GMT Received: from localhost ([10.140.178.105]) by demuprx017.emea.nsn-intra.net (8.12.11.20060308/8.12.11) with ESMTP id t7494I5M025242; Tue, 4 Aug 2015 11:04:19 +0200 From: chixiaobo To: dev@dpdk.org Date: Tue, 4 Aug 2015 17:04:18 +0800 Message-Id: <1438679058-18324-1-git-send-email-xiaobo.chi@nokia.com> X-Mailer: git-send-email 1.9.4.msysgit.2 X-purgate-type: clean X-purgate-Ad: Categorized by eleven eXpurgate (R) http://www.eleven.de X-purgate: clean X-purgate: This mail is considered clean (visit http://www.eleven.de for further information) X-purgate-size: 1554 X-purgate-ID: 151667::1438679060-000063FD-72DD8AFA/0/0 X-Mailman-Approved-At: Tue, 04 Aug 2015 11:45:00 +0200 Cc: chixiaobo Subject: [dpdk-dev] [PATCH] array malloced by backtrace_symbols() should be freed by the caller 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: Tue, 04 Aug 2015 09:04:21 -0000 As to linux man page: http://linux.die.net/man/3/backtrace_symbols, The address of the array of string pointers is returned as the function result of backtrace_symbols(). This array is malloced by backtrace_symbols(), and must be freed by the caller. The strings pointed to by the array of pointers need not and should not be freed. Signed-off-by: chixiaobo --- lib/librte_eal/bsdapp/eal/eal_debug.c | 3 +++ lib/librte_eal/linuxapp/eal/eal_debug.c | 3 +++ 2 files changed, 6 insertions(+) diff --git a/lib/librte_eal/bsdapp/eal/eal_debug.c b/lib/librte_eal/bsdapp/eal/eal_debug.c index 44fc4f3..ceca2e8 100644 --- a/lib/librte_eal/bsdapp/eal/eal_debug.c +++ b/lib/librte_eal/bsdapp/eal/eal_debug.c @@ -58,6 +58,9 @@ void rte_dump_stack(void) "%d: [%s]\n", size, symb[size - 1]); size --; } + /* This array is malloced by backtrace_symbols(), and must be freed by the caller */ + if( symb ) + free( (void *)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..ceca2e8 100644 --- a/lib/librte_eal/linuxapp/eal/eal_debug.c +++ b/lib/librte_eal/linuxapp/eal/eal_debug.c @@ -58,6 +58,9 @@ void rte_dump_stack(void) "%d: [%s]\n", size, symb[size - 1]); size --; } + /* This array is malloced by backtrace_symbols(), and must be freed by the caller */ + if( symb ) + free( (void *)symb ); } /* not implemented in this environment */ -- 1.9.4.msysgit.2