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 88509428D4 for ; Wed, 5 Apr 2023 18:04:45 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 812DE42D0D; Wed, 5 Apr 2023 18:04:45 +0200 (CEST) Received: from mga04.intel.com (mga04.intel.com [192.55.52.120]) by mails.dpdk.org (Postfix) with ESMTP id 45463427E9; Wed, 5 Apr 2023 18:04:42 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1680710682; x=1712246682; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=vyG6oyrJvzCQDUTMUwfJrdN9vsdcCdtrQddmeHIlMYc=; b=a83PFlhZj2aEoR7Yq5W/3T6qwd2QiaYhpEHIsZMQbC8pqa102kMB6l3/ p7CRENd5lo6a0o2IjEtK5xkhL9gkLXyYyzDrgxq8Kef1tZKt+TgSZlv7u TDVCCI9L3p+NIu+wERVon/NZg38cgR976QnzARaRnNNJ0DBbUwKKw+y33 CFzbbFm9LwjTEVDQcq96W5HoQcZxFN6SBO005DJo1sTfEMNQCrJBUZUB+ H/j1/aKPKISotkdmhrKEbIG9sjmtgSL5gW1n1mi0YpTYKME0pO1BfZWlU 1jF6GyjRIn0W9lVW6HuWPTghTWjXTrPyX0YAawrndsIMFHk/gBo9a3hdz w==; X-IronPort-AV: E=McAfee;i="6600,9927,10671"; a="341218587" X-IronPort-AV: E=Sophos;i="5.98,321,1673942400"; d="scan'208";a="341218587" Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by fmsmga104.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 05 Apr 2023 09:04:18 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10671"; a="830405799" X-IronPort-AV: E=Sophos;i="5.98,321,1673942400"; d="scan'208";a="830405799" Received: from silpixa00401385.ir.intel.com ([10.237.214.40]) by fmsmga001.fm.intel.com with ESMTP; 05 Apr 2023 09:04:16 -0700 From: Bruce Richardson To: dev@dpdk.org Cc: ciara.power@intel.com, roretzla@linux.microsoft.com, Bruce Richardson , stable@dpdk.org Subject: [PATCH v3 1/5] telemetry: fix autotest failures on Alpine Date: Wed, 5 Apr 2023 17:03:22 +0100 Message-Id: <20230405160326.186921-2-bruce.richardson@intel.com> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20230405160326.186921-1-bruce.richardson@intel.com> References: <20230310181836.162336-1-bruce.richardson@intel.com> <20230405160326.186921-1-bruce.richardson@intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-BeenThere: stable@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: patches for DPDK stable branches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: stable-bounces@dpdk.org On Alpine linux, the telemetry_data_autotest was failing for the test where we had dictionaries embedded in other dictionaries up to three levels deep. Indications are that this issue is due to excess data being stored on the stack, so replace stack-allocated buffer data with dynamically allocated data in the case where we are doing recursive processing of telemetry data structures into json. Bugzilla ID: 1177 Fixes: c933bb5177ca ("telemetry: support array values in data object") Fixes: d2671e642a8e ("telemetry: support dict of dicts") Cc: stable@dpdk.org Signed-off-by: Bruce Richardson --- V2: set '\0' in newly malloc'ed buffer to ensure it always has valid string data. --- lib/telemetry/telemetry.c | 21 ++++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) diff --git a/lib/telemetry/telemetry.c b/lib/telemetry/telemetry.c index 7bceadcee7..728a0bffd4 100644 --- a/lib/telemetry/telemetry.c +++ b/lib/telemetry/telemetry.c @@ -208,7 +208,11 @@ container_to_json(const struct rte_tel_data *d, char *out_buf, size_t buf_len) break; case RTE_TEL_CONTAINER: { - char temp[buf_len]; + char *temp = malloc(buf_len); + if (temp == NULL) + break; + *temp = '\0'; /* ensure valid string */ + const struct container *cont = &v->value.container; if (container_to_json(cont->data, @@ -219,6 +223,7 @@ container_to_json(const struct rte_tel_data *d, char *out_buf, size_t buf_len) v->name, temp); if (!cont->keep) rte_tel_data_free(cont->data); + free(temp); break; } } @@ -275,7 +280,11 @@ output_json(const char *cmd, const struct rte_tel_data *d, int s) break; case RTE_TEL_CONTAINER: { - char temp[buf_len]; + char *temp = malloc(buf_len); + if (temp == NULL) + break; + *temp = '\0'; /* ensure valid string */ + const struct container *cont = &v->value.container; if (container_to_json(cont->data, @@ -286,6 +295,7 @@ output_json(const char *cmd, const struct rte_tel_data *d, int s) v->name, temp); if (!cont->keep) rte_tel_data_free(cont->data); + free(temp); } } } @@ -311,7 +321,11 @@ output_json(const char *cmd, const struct rte_tel_data *d, int s) buf_len, used, d->data.array[i].uval); else if (d->type == TEL_ARRAY_CONTAINER) { - char temp[buf_len]; + char *temp = malloc(buf_len); + if (temp == NULL) + break; + *temp = '\0'; /* ensure valid string */ + const struct container *rec_data = &d->data.array[i].container; if (container_to_json(rec_data->data, @@ -321,6 +335,7 @@ output_json(const char *cmd, const struct rte_tel_data *d, int s) buf_len, used, temp); if (!rec_data->keep) rte_tel_data_free(rec_data->data); + free(temp); } break; } -- 2.37.2