From mboxrd@z Thu Jan  1 00:00:00 1970
Return-Path: <dev-bounces@dpdk.org>
Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124])
	by inbox.dpdk.org (Postfix) with ESMTP id 6FBC241EB2;
	Thu, 16 Mar 2023 20:15:39 +0100 (CET)
Received: from mails.dpdk.org (localhost [127.0.0.1])
	by mails.dpdk.org (Postfix) with ESMTP id 9944242F82;
	Thu, 16 Mar 2023 20:15:32 +0100 (CET)
Received: from mail-lf1-f48.google.com (mail-lf1-f48.google.com
 [209.85.167.48]) by mails.dpdk.org (Postfix) with ESMTP id DFB3C40DF6
 for <dev@dpdk.org>; Thu, 16 Mar 2023 20:15:29 +0100 (CET)
Received: by mail-lf1-f48.google.com with SMTP id b10so2466960lfb.9
 for <dev@dpdk.org>; Thu, 16 Mar 2023 12:15:29 -0700 (PDT)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
 d=nfware.com; s=google; t=1678994129;
 h=content-transfer-encoding:mime-version:references:in-reply-to
 :message-id:date:subject:cc:to:from:from:to:cc:subject:date
 :message-id:reply-to;
 bh=qndQzR3w927IKvnjjKx4SuAAR/+5nVxiRJUjz0M9Mbw=;
 b=a78wzyiBzppw02ggVAx+xCK/X8xdd1X8xkb2cFCdwNTNtkxYeXSlvgcpvaePr8bbI/
 eDpkt/rPmCYANfjdclAMCB1dLk1dfv+cvljH2aEWLooex5KcO3i8WmQDZB2MHEMR69NB
 2z6DoWM3qh0lp0y0Ew3h5hg/PCV7BvG76CY1GgF4N1AdgBDHpBBHiMXvwhIeTU2dksDk
 dFGOnZvEY9Rra6pgG9z7f+TBsBcL4NAiwsg7GGZDaLCRaV/31zpnMMG9weHRPrnA/GNy
 DIq2+HLHhqseaoUeRlY68HNyH+7l2wivX/yaMQeZg2rAyDF0kzGrcQkbWMc8TvRuJHzN
 FF5w==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
 d=1e100.net; s=20210112; t=1678994129;
 h=content-transfer-encoding:mime-version:references:in-reply-to
 :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc
 :subject:date:message-id:reply-to;
 bh=qndQzR3w927IKvnjjKx4SuAAR/+5nVxiRJUjz0M9Mbw=;
 b=Mg1vTDWBPtcKwCeJXEpny90SDbEB9wXM25/aS1Cdk/WDwfzqQY4fmdrLs8IKKV1j/9
 uhOtrWhKYQto5gHwny1U5LssC8G5GoPGyOg+bCZ+FOvxpJLKtK3IJLA38qMFiGs75inp
 cZTvnzpDGyHMoczhiSOQHumxfh1LipVzUbw8vB6lS8C1GNGOMbETIgnawYWhzWe8b+ih
 mIPHOBbLvzF9LMN1SxjeHut8rJ3/lpuxuMom1OlrnK/pFO4q0goOpXJyKWVduz1VzRA4
 pX+s9fYCo/hwsEHo0OxwmM0AIeA8MkucfgIukeqJI/F+jrXCgEPWs7zspRVqQSk5DoB9
 lyBw==
X-Gm-Message-State: AO0yUKXKO4YfodW7onF7SsDeEanDjDP0UyfRqhYTpiHnNY73HfMWtE56
 mA6QZl0OQcR5Pu5U88dxfd+CBA==
X-Google-Smtp-Source: AK7set8+WCB/gylqDNaAXe34u6EXMCG8lytn1NKQhDY8SqspklFHoExYIcjkrwu9kVsoRqNgpY99dw==
X-Received: by 2002:a19:760f:0:b0:4d8:5e8e:b138 with SMTP id
 c15-20020a19760f000000b004d85e8eb138mr3416766lff.14.1678994129268; 
 Thu, 16 Mar 2023 12:15:29 -0700 (PDT)
Received: from zays-home.int.nfware.com (95-31-178-75.broadband.corbina.ru.
 [95.31.178.75]) by smtp.gmail.com with ESMTPSA id
 d1-20020ac25ec1000000b004d5813386fdsm8158lfq.139.2023.03.16.12.15.28
 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);
 Thu, 16 Mar 2023 12:15:28 -0700 (PDT)
From: Pavel Ivashchenko <pivashchenko@nfware.com>
To: Olivier Matz <olivier.matz@6wind.com>,
	Konstantin Ananyev <"konstantin.v.ananyev@yandex.rukonstantin.ananyev"@huawei.com>,
	=?UTF-8?q?Morten=20Br=C3=B8rup?= <mb@smartsharesystems.com>,
	Ajit Khaparde <ajit.khaparde@broadcom.com>
Cc: dev@dpdk.org, Pavel Ivashchenko <pivashchenko@nfware.com>, stable@dpdk.org
Subject: [PATCH v2 1/1] test/mbuf: fix mbuf autotest when mbuf debug is enabled
Date: Thu, 16 Mar 2023 22:14:56 +0300
Message-Id: <20230316191456.54066-1-pivashchenko@nfware.com>
X-Mailer: git-send-email 2.39.0
In-Reply-To: <20230313165605.12325-1-pivashchenko@nfware.com>
References: <20230313165605.12325-1-pivashchenko@nfware.com>
MIME-Version: 1.0
Content-Transfer-Encoding: 8bit
X-BeenThere: dev@dpdk.org
X-Mailman-Version: 2.1.29
Precedence: list
List-Id: DPDK patches and discussions <dev.dpdk.org>
List-Unsubscribe: <https://mails.dpdk.org/options/dev>,
 <mailto:dev-request@dpdk.org?subject=unsubscribe>
List-Archive: <http://mails.dpdk.org/archives/dev/>
List-Post: <mailto:dev@dpdk.org>
List-Help: <mailto:dev-request@dpdk.org?subject=help>
List-Subscribe: <https://mails.dpdk.org/listinfo/dev>,
 <mailto:dev-request@dpdk.org?subject=subscribe>
Errors-To: dev-bounces@dpdk.org

How to reproduce:

1. Define RTE_LIBRTE_MBUF_DEBUG
2. MALLOC_PERTURB_=178 DPDK_TEST=mbuf_autotest gdb --args obj-x86_64-linux-gnu/app/test/dpdk-test --file-prefix=mbuf_autotest

   PANIC in rte_mbuf_sanity_check():
   bad pkt_len

   ...
   #6  0x00007ffff7d3d4cc in rte_mbuf_sanity_check (m=m@entry=0x17f8c3400, is_header=is_header@entry=1) at ../lib/mbuf/rte_mbuf.c:384
   #7  0x0000555555653d57 in rte_pktmbuf_free (m=0x17f8c3400) at ../lib/mbuf/rte_mbuf.h:1385
   #8  0x000055555565c7a6 in test_nb_segs_and_next_reset () at ../app/test/test_mbuf.c:2752
   #9  test_mbuf () at ../app/test/test_mbuf.c:2967
   ...

   (gdb) frame 6
   #6  0x00007ffff7d3d4cc in rte_mbuf_sanity_check (m=m@entry=0x17f8c3400, is_header=is_header@entry=1) at ../lib/mbuf/rte_mbuf.c:384
   384			rte_panic("%s\n", reason);
   (gdb) p/d m->pkt_len
   $4 = 1500

Fixes: efc6f9104c80 ("mbuf: fix reset on mbuf free")
Cc: stable@dpdk.org

Signed-off-by: Pavel Ivashchenko <pivashchenko@nfware.com>
---
v2:
 * Fixed commit title
 * Changed m0->pkt_len -= 500 to m0->pkt_len -= m2->data_len

 app/test/test_mbuf.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/app/test/test_mbuf.c b/app/test/test_mbuf.c
index 6cbb03b0af..1f4dd62466 100644
--- a/app/test/test_mbuf.c
+++ b/app/test/test_mbuf.c
@@ -2744,6 +2744,7 @@ test_nb_segs_and_next_reset(void)
 
 	/* split m0 chain in two, between m1 and m2 */
 	m0->nb_segs = 2;
+	m0->pkt_len -= m2->data_len;
 	m1->next = NULL;
 	m2->nb_segs = 1;
 
-- 
2.39.0