From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail.droids-corp.org (zoll.droids-corp.org [94.23.50.67]) by dpdk.org (Postfix) with ESMTP id 63BE55693 for ; Mon, 1 Jun 2015 11:45:43 +0200 (CEST) Received: from was59-1-82-226-113-214.fbx.proxad.net ([82.226.113.214] helo=[192.168.0.10]) by mail.droids-corp.org with esmtpsa (TLS1.2:DHE_RSA_AES_128_CBC_SHA1:128) (Exim 4.80) (envelope-from ) id 1YzMMH-0005YX-JY; Mon, 01 Jun 2015 11:50:17 +0200 Message-ID: <556C29DF.2050602@6wind.com> Date: Mon, 01 Jun 2015 11:46:07 +0200 From: Olivier MATZ User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Icedove/31.6.0 MIME-Version: 1.0 To: Jan Blunck , dev@dpdk.org References: <1432895688-1728-1-git-send-email-jblunck@infradead.org> <1433151038-630-1-git-send-email-jblunck@infradead.org> In-Reply-To: <1433151038-630-1-git-send-email-jblunck@infradead.org> Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: 7bit Subject: Re: [dpdk-dev] [PATCH v2] log: Properly reset log_history_size in rte_log_dump_history() 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, 01 Jun 2015 09:45:43 -0000 On 06/01/2015 11:30 AM, Jan Blunck wrote: > In rte_log_dump_history() the log_history list is reinitialized without > resetting the log_history_size. In the next call to rte_log_add_in_history() > the log_history_size > RTE_LOG_HISTORY and the code unconditionally tries > to remove the first entry: > > Program received signal SIGSEGV, Segmentation fault. > rte_log_add_in_history ( > buf=buf@entry=0x7f02035cd000 "DATAPLANE: 9:dp0s7 link RTM_NEWLINK [dp0s7] \nCAST,LOWER_UP>\n", size=size@entry=86) > at /usr/src/packages/BUILD/lib/librte_eal/common/eal_common_log.c:122 > > Signed-off-by: Jan Blunck Acked-by: Olivier Matz > --- > lib/librte_eal/common/eal_common_log.c | 6 +++++- > 1 file changed, 5 insertions(+), 1 deletion(-) > > diff --git a/lib/librte_eal/common/eal_common_log.c b/lib/librte_eal/common/eal_common_log.c > index fe3d7d5..39d6e3f 100644 > --- a/lib/librte_eal/common/eal_common_log.c > +++ b/lib/librte_eal/common/eal_common_log.c > @@ -119,7 +119,10 @@ rte_log_add_in_history(const char *buf, size_t size) > /* get a buffer for adding in history */ > if (log_history_size > RTE_LOG_HISTORY) { > hist_buf = STAILQ_FIRST(&log_history); > - STAILQ_REMOVE_HEAD(&log_history, next); > + if (hist_buf) { > + STAILQ_REMOVE_HEAD(&log_history, next); > + log_history_size--; > + } > } > else { > if (rte_mempool_mc_get(log_history_mp, &obj) < 0) > @@ -234,6 +237,7 @@ rte_log_dump_history(FILE *out) > rte_spinlock_lock(&log_list_lock); > tmp_log_history = log_history; > STAILQ_INIT(&log_history); > + log_history_size = 0; > rte_spinlock_unlock(&log_list_lock); > > for (i=0; i