From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id B7F764614D; Thu, 30 Jan 2025 20:10:47 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 4289840275; Thu, 30 Jan 2025 20:10:47 +0100 (CET) Received: from mail-pj1-f45.google.com (mail-pj1-f45.google.com [209.85.216.45]) by mails.dpdk.org (Postfix) with ESMTP id 9947D4025A for ; Thu, 30 Jan 2025 20:10:46 +0100 (CET) Received: by mail-pj1-f45.google.com with SMTP id 98e67ed59e1d1-2f4448bf96fso1605578a91.0 for ; Thu, 30 Jan 2025 11:10:46 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=networkplumber-org.20230601.gappssmtp.com; s=20230601; t=1738264245; x=1738869045; darn=dpdk.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:subject:cc:to:from:date:from:to:cc:subject:date :message-id:reply-to; bh=eOVM5fieRGDGZZ1COhwofECvnNarxh8U9qPXUfQbgnY=; b=la37V8KsQO5DjsVUQoUZIT92jeSraq/mUUGCBboKgaFMLuqwkhRj9ivrJyJUA3TBCu Klho8CEH39oA897syyl2FDdHPbhISQNc02uV22Rf5PMDl1zqfMYTY4zO/zgOUrtAIYH6 qYwkU9Qi0g5Kco4P42BlfvLAFCZpifyOZXQcT5odnnuXYCEZ9PsvLpg3pYy2t4wxOGDH 9ohSbFQvsPfPVubwFvWEnn999ikbn9b0LpylG7jsG7BhPKBSBT3AvqFkW8o6f0R/LKdm vnbY5XX/kvnhxBNtqvAvbL8j+uqNbJO9SD7qspApWpC43dGdXpxJJpR4eFOmgT5GgJTH U3sQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1738264245; x=1738869045; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:subject:cc:to:from:date:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=eOVM5fieRGDGZZ1COhwofECvnNarxh8U9qPXUfQbgnY=; b=r5ASERHIboZm4F12Iqfa1zUQxguvyfF0vW9/02AQVB5FL/Xs3IPzHtKjzR+KugYIM/ UzmMqlFzFrV+jhZePh1IcyXUD5MCE4FIhLVukdlS2ITHzKzmcaUhCuZV0ot6eEk3WGhS W8JOUpUtdY1XAPWYXjn4bfuH4zuujGqDNjwpQo5suROU7rXkbPPdpCKNt0W5yJAPwUlh rl9vdNVWVpgRrqmeVFrAFuXyfNvePo7iv4evlf8tvdfRd0VBRRRuxd4YTWPTZvj1qiu/ N+Hv2fkkFMWlGK/0VkXHCG7RvdnZkbJQWjqhMl0Xot6gfIpk0N/PykaMRn/hHDoyx1Lr 8Vgg== X-Gm-Message-State: AOJu0YxqS//OAcGVQCgmmvPtLHehLHQty8BikdARaG/yi4jR49pe6TV9 51SZMio8l+Mfc9By1azk96oRbSxv5nSdyTLmlbuIkFviC4jai5hTICzXIRmmvjs= X-Gm-Gg: ASbGnctqTvAMG3Au3t4mPG6UQ8ff4zaqPrtsej+NUt8M8WgpIfcCQgW/9+zqq3ZRI5o 1+NhEt4v8vLg7XLJ6DWbVdl2b3YqMIXsc+1EeIUG6b0GQafSVCFI/P5Wxr9ySc6gEFRuGIJC+cs uIeH7fOW+Mz9xqk2PfpAQfTCKUziF0WqW1sZxgeqXRFwytCBxuRQJ8eoo8GEh6+GW0UlMH+R33k bSMruyqQfMg6VTxzHUW0gWevld+iIFHKtMUvYZSCsfA5PqyjjHo7543eWzOQYWobCH/P7a6Hn45 U48ubPmYc+AL0Z5niLFAP6ERunm/Y2xOk+IJ7TvCpphbWIg3wdR0tfsDzKAlRYgP1yrB X-Google-Smtp-Source: AGHT+IFGH6cP7g6/lNUg14ODOEdZKSTuGRMcUNvpu1FLuuIpQnIScWLOIJJLwV3V3Qk0V+ueSHgyXg== X-Received: by 2002:a05:6a00:1412:b0:725:f153:22d5 with SMTP id d2e1a72fcca58-72fd0c623damr11875809b3a.18.1738264245486; Thu, 30 Jan 2025 11:10:45 -0800 (PST) Received: from hermes.local (204-195-96-226.wavecable.com. [204.195.96.226]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-72fe69ce054sm1841622b3a.132.2025.01.30.11.10.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 30 Jan 2025 11:10:45 -0800 (PST) Date: Thu, 30 Jan 2025 11:10:43 -0800 From: Stephen Hemminger To: David Marchand Cc: dev@dpdk.org, Chengwen Feng , Kevin Laatz , Bruce Richardson , Jerin Jacob , Sunil Kumar Kori , Tyler Retzlaff Subject: Re: [PATCH v2 3/3] trace: fix undefined behavior in register Message-ID: <20250130111043.76b8cd2c@hermes.local> In-Reply-To: <20250130145849.82003-3-david.marchand@redhat.com> References: <20250124161408.310581-1-david.marchand@redhat.com> <20250130145849.82003-1-david.marchand@redhat.com> <20250130145849.82003-3-david.marchand@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org On Thu, 30 Jan 2025 15:58:49 +0100 David Marchand wrote: > Registering a tracepoint handler was resulting so far in undefined > behavior at runtime. >=20 > The RTE_TRACE_POINT_REGISTER() macro was casting the tracepoint handler > (which expects arguments) to a void (*)(void). > At runtime, calling this handler while registering resulted in > reading the current stack with no relation to this function prototype. >=20 > Instead, declare an additional inline _register() handler for each > tracepoint and make sure that the emitting macros in > rte_trace_point_register.h only work on arguments name and type. >=20 > The original tracepoint handler prototype is adjusted by adding a > __rte_unused for each argument (since emitting macros do nothing > with them). > This last part introduces an implementation limit of 15 arguments. >=20 > With this change in place, the workaround in dmadev tracepoints can be > removed. >=20 > Signed-off-by: David Marchand When I build with -Db_santize=3Dundefined the following warning shows up. It seems related. In function =E2=80=98rte_ethdev_trace_get_dcb_info=E2=80=99, inlined from =E2=80=98rte_eth_dev_get_dcb_info=E2=80=99 at ../lib/ethde= v/rte_ethdev.c:6720:2: ../lib/eal/include/rte_trace_point.h:381:9: warning: writing 1 byte into a = region of size 0 [-Wstringop-overflow=3D] 381 | memcpy(mem, &(in), sizeof(in)); \ | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ../lib/eal/include/rte_trace_point.h:53:9: note: in definition of macro =E2= =80=98__RTE_TRACE_POINT=E2=80=99 53 | __VA_ARGS__ \ | ^~~~~~~~~~~ ../lib/ethdev/ethdev_trace.h:1213:1: note: in expansion of macro =E2=80=98R= TE_TRACE_POINT=E2=80=99 1213 | RTE_TRACE_POINT( | ^~~~~~~~~~~~~~~ ../lib/eal/include/rte_trace_point.h:399:9: note: in expansion of macro =E2= =80=98__rte_trace_point_emit=E2=80=99 399 | __rte_trace_point_emit(len, uint8_t); \ | ^~~~~~~~~~~~~~~~~~~~~~ ../lib/ethdev/ethdev_trace.h:1223:9: note: in expansion of macro =E2=80=98r= te_trace_point_emit_blob=E2=80=99 1223 | rte_trace_point_emit_blob(dcb_info->tc_bws, num_tcs); | ^~~~~~~~~~~~~~~~~~~~~~~~~ In function =E2=80=98rte_eth_dev_get_dcb_info=E2=80=99: cc1: note: destination object is likely at address zero In function =E2=80=98rte_ethdev_trace_get_dcb_info=E2=80=99, inlined from =E2=80=98rte_eth_dev_get_dcb_info=E2=80=99 at ../lib/ethde= v/rte_ethdev.c:6720:2: ../lib/eal/include/rte_trace_point.h:401:9: warning: =E2=80=98memset=E2=80= =99 offset [0, 55] is out of the bounds [0, 0] [-Warray-bounds=3D] 401 | memset(RTE_PTR_ADD(mem, len), 0, RTE_TRACE_BLOB_LEN_MAX - l= en); \ | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~= ~~~ ../lib/eal/include/rte_trace_point.h:53:9: note: in definition of macro =E2= =80=98__RTE_TRACE_POINT=E2=80=99 53 | __VA_ARGS__ \ | ^~~~~~~~~~~ ../lib/ethdev/ethdev_trace.h:1213:1: note: in expansion of macro =E2=80=98R= TE_TRACE_POINT=E2=80=99 1213 | RTE_TRACE_POINT( | ^~~~~~~~~~~~~~~ ../lib/ethdev/ethdev_trace.h:1222:9: note: in expansion of macro =E2=80=98r= te_trace_point_emit_blob=E2=80=99 1222 | rte_trace_point_emit_blob(dcb_info->prio_tc, num_user_prior= ities);