From mboxrd@z Thu Jan 1 00:00:00 1970 From: Stephen Hemminger Subject: Re: [PATCH] array malloced by backtrace_symbols() should be freed by the caller Date: Tue, 4 Aug 2015 09:12:23 -0700 Message-ID: <20150804091223.4e7142c6@urahara> References: <1438679058-18324-1-git-send-email-xiaobo.chi@nokia.com> Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Cc: dev@dpdk.org To: chixiaobo Return-path: Received: from mail-pa0-f46.google.com (mail-pa0-f46.google.com [209.85.220.46]) by dpdk.org (Postfix) with ESMTP id 623A120F for ; Tue, 4 Aug 2015 18:12:14 +0200 (CEST) Received: by pawu10 with SMTP id u10so11964551paw.1 for ; Tue, 04 Aug 2015 09:12:13 -0700 (PDT) In-Reply-To: <1438679058-18324-1-git-send-email-xiaobo.chi@nokia.com> List-Id: patches and discussions about DPDK List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" On Tue, 4 Aug 2015 17:04:18 +0800 chixiaobo wrote: > 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 ); I agree that free() should probably be done, but am a little worried that it just make things break. Since lots of times when this code is called the malloc pool is in broken state because the whole reason for calling backtrace is to handle panic situation. Please use the standard white space style, and do not add a cast to void * where none is required in C. On a related note, I found that backtrace_symbols was rather poor at decoding and finding many symbols. The unwind library does a better job.