From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-wi0-f179.google.com (mail-wi0-f179.google.com [209.85.212.179]) by dpdk.org (Postfix) with ESMTP id CE45658E4 for ; Fri, 29 May 2015 12:35:25 +0200 (CEST) Received: by wizo1 with SMTP id o1so18063009wiz.1 for ; Fri, 29 May 2015 03:35:25 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=sender:from:to:subject:date:message-id; bh=BTBbDKfMcNtJyDkE+oYJCGnaLicmoq8NGeFczomseZM=; b=HqmDRAFpHJtHIRSJkvsrWwU5lfuBkSho2+kcahR09Zzub0BSwrCT+WyfR9s3ewtQ8f DLr6bv/aSzx2fJnjE/ZYNnIoPxL9/H1WfV/BbPN+9gv5qZm4GYYQ0JZlO8xP0eaJw8GO UvhcYVq+g6hrrt74ZuazDYMcK0qlotp3B3uQ7TmEg1abHV+7gI4Hg3/4/g3BvO+EX9B2 kp7S0Iby27kfbwJk0AC4bQtFdndldm7/NIrRNFGhKreSEaCCsGbfhMqHxPdpLgpuPfj6 qyszaPF9mIpJGaz9FVyhx07InB5HZW8yen61oJU5jFyrQPsG6OYc9gzUlasArTJXeRqg iHMQ== X-Received: by 10.180.14.193 with SMTP id r1mr5015645wic.47.1432895725657; Fri, 29 May 2015 03:35:25 -0700 (PDT) Received: from linux-04uu.site.eng.vyatta.net (port-92-196-75-134.dynamic.qsc.de. [92.196.75.134]) by mx.google.com with ESMTPSA id ny7sm2463585wic.11.2015.05.29.03.35.24 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 29 May 2015 03:35:25 -0700 (PDT) Sender: Jan Blunck From: Jan Blunck To: dev@dpdk.org Date: Fri, 29 May 2015 12:34:48 +0200 Message-Id: <1432895688-1728-1-git-send-email-jblunck@infradead.org> X-Mailer: git-send-email 2.1.4 Subject: [dpdk-dev] [PATCH] 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: Fri, 29 May 2015 10:35:26 -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 | 4 +++- 1 file changed, 3 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..cb4311c 100644 --- a/lib/librte_eal/common/eal_common_log.c +++ b/lib/librte_eal/common/eal_common_log.c @@ -119,7 +119,8 @@ 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); } else { if (rte_mempool_mc_get(log_history_mp, &obj) < 0) @@ -234,6 +235,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