From: James Clark <james.clark@arm.com>
To: Ilkka Koskinen <ilkka@os.amperecomputing.com>
Cc: linux-perf-users@vger.kernel.org, linux-kernel@vger.kernel.org,
Peter Zijlstra <peterz@infradead.org>,
Ingo Molnar <mingo@redhat.com>,
Arnaldo Carvalho de Melo <acme@kernel.org>,
Mark Rutland <mark.rutland@arm.com>,
Alexander Shishkin <alexander.shishkin@linux.intel.com>,
Jiri Olsa <jolsa@kernel.org>, Namhyung Kim <namhyung@kernel.org>,
Ian Rogers <irogers@google.com>,
Adrian Hunter <adrian.hunter@intel.com>
Subject: Re: [PATCH] perf data convert: Fix segfault when converting to json on arm64
Date: Fri, 12 Jan 2024 11:35:27 +0000 [thread overview]
Message-ID: <2c9f5893-450c-012b-b748-a8fe8ddfae86@arm.com> (raw)
In-Reply-To: <20240111232923.8138-1-ilkka@os.amperecomputing.com>
On 11/01/2024 23:29, Ilkka Koskinen wrote:
> Arm64 doesn't have Model in /proc/cpuinfo and, thus, cpu_desc doesn't get
> assigned.
>
> Running
> $ perf data convert --to-json perf.data.json
>
> ends up calling output_json_string() with NULL pointer, which causes a
> segmentation fault.
>
> Signed-off-by: Ilkka Koskinen <ilkka@os.amperecomputing.com>
> ---
> tools/perf/util/data-convert-json.c | 5 +++++
> 1 file changed, 5 insertions(+)
>
> diff --git a/tools/perf/util/data-convert-json.c b/tools/perf/util/data-convert-json.c
> index 5bb3c2ba95ca..5d6de1cef546 100644
> --- a/tools/perf/util/data-convert-json.c
> +++ b/tools/perf/util/data-convert-json.c
> @@ -97,6 +97,11 @@ static void output_json_format(FILE *out, bool comma, int depth, const char *for
> static void output_json_key_string(FILE *out, bool comma, int depth,
> const char *key, const char *value)
> {
> + if (!value) {
> + pr_info("No value set for key %s\n", key);
> + return;
> + }
> +
> output_json_delimiters(out, comma, depth);
> output_json_string(out, key);
> fputs(": ", out);
It looks like this would hide new errors on any of the other fields that
output_json_key_string() is called on. Maybe it would be better to only
wrap the call to output cpu_desc with the if? If that's the only one
that we think is optional, and even better only do it for arm64.
I mention this because the test for 'perf data convert' only checks for
valid json syntax, but not any fields. So we might want to avoid others
going missing.
Thanks
James
next prev parent reply other threads:[~2024-01-12 11:35 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-01-11 23:29 [PATCH] perf data convert: Fix segfault when converting to json on arm64 Ilkka Koskinen
2024-01-12 11:35 ` James Clark [this message]
2024-01-16 21:53 ` Namhyung Kim
2024-01-17 4:47 ` Ilkka Koskinen
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=2c9f5893-450c-012b-b748-a8fe8ddfae86@arm.com \
--to=james.clark@arm.com \
--cc=acme@kernel.org \
--cc=adrian.hunter@intel.com \
--cc=alexander.shishkin@linux.intel.com \
--cc=ilkka@os.amperecomputing.com \
--cc=irogers@google.com \
--cc=jolsa@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-perf-users@vger.kernel.org \
--cc=mark.rutland@arm.com \
--cc=mingo@redhat.com \
--cc=namhyung@kernel.org \
--cc=peterz@infradead.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).