From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-wg0-f46.google.com (mail-wg0-f46.google.com [74.125.82.46]) by dpdk.org (Postfix) with ESMTP id 9AF2F58C3 for ; Mon, 1 Jun 2015 11:30:53 +0200 (CEST) Received: by wgez8 with SMTP id z8so108895340wge.0 for ; Mon, 01 Jun 2015 02:30:53 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references; bh=/01MhQH12sJB3e4m1Eoc5M/ymjUsTKQNv22Hp3GFOyI=; b=tONwqUebhgO/kbr5tYwinXDG+IxpTpuPTa6ml+Y8Ypv2UaSKq6EJQ6X4RHMY1O4NMN x8GwM6k6dAzrzb5IrWV1zpVeN1Sothc0OvcFvDKoZveuKPYcrY3PqyccFzapaD/w7Gmo r/tMxlXDQyxpNVr5/nnmrKN5boGtCVjouqIN5/bQhkrh+wrGGg1cWbpITeExKYdrdJhV Iro0auWURtXCswbp4QvvUbewBOowTV7zO8CwNXWn3Jl/pa/IfzH8BkefSEINpDagyBQ9 8lGAM/1YH40ezwlae/vaHZm37otWFWnmmvjo2H4rTY1D6E0HHRC6rVUofZ9z5PNJQ7pn 8Htg== X-Received: by 10.194.3.11 with SMTP id 11mr1950155wjy.121.1433151053488; Mon, 01 Jun 2015 02:30:53 -0700 (PDT) Received: from linux-04uu.site.eng.vyatta.net (port-92-196-73-168.dynamic.qsc.de. [92.196.73.168]) by mx.google.com with ESMTPSA id js3sm20980214wjc.5.2015.06.01.02.30.52 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 01 Jun 2015 02:30:52 -0700 (PDT) Sender: Jan Blunck From: Jan Blunck To: dev@dpdk.org Date: Mon, 1 Jun 2015 11:30:38 +0200 Message-Id: <1433151038-630-1-git-send-email-jblunck@infradead.org> X-Mailer: git-send-email 2.1.4 In-Reply-To: <1432895688-1728-1-git-send-email-jblunck@infradead.org> References: <1432895688-1728-1-git-send-email-jblunck@infradead.org> Subject: [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:30:53 -0000 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 --- 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