From: "James O. D. Hunt" <james.o.hunt@intel.com>
To: linux-perf-users@vger.kernel.org, Ingo Molnar <mingo@redhat.com>,
Arnaldo Carvalho de Melo <acme@kernel.org>,
Namhyung Kim <namhyung@kernel.org>,
Mark Rutland <mark.rutland@arm.com>,
Alexander Shishkin <alexander.shishkin@linux.intel.com>,
Jiri Olsa <jolsa@kernel.org>, Ian Rogers <irogers@google.com>,
Adrian Hunter <adrian.hunter@intel.com>,
"Liang, Kan" <kan.liang@linux.intel.com>
Cc: linux-kernel@vger.kernel.org,
"James O . D . Hunt" <james.o.hunt@intel.com>
Subject: [PATCH] perf: Fix JSON output crash with intel_pt// samples
Date: Mon, 7 Apr 2025 17:22:11 +0100 [thread overview]
Message-ID: <20250407162211.172951-1-james.o.hunt@intel.com> (raw)
Current behaviour:
```bash
$ perf record -e intel_pt// true
$ perf data convert --to-json /tmp/perf.json
Segmentation fault (core dumped)
```
With fix applied:
```bash
$ perf record -e intel_pt// true
$ perf data convert --to-json /tmp/perf.json
$ jq < /tmp/perf.json &>/dev/null && echo ok
ok
```
The crash actually occurs in `intel_pt_process_auxtrace_info()` where
`session->itrace_synth_opts->set` is unconditionally dereferenced. This
platform-specific code could be changed to fix the issue, but this patch
fixes the problem generally.
Fixes: f6986c95af84ff2a76847910b4322f542b793bbf ("perf session: Add instruction tracing options")
Signed-off-by: James O. D. Hunt <james.o.hunt@intel.com>
---
tools/perf/util/data-convert-json.c | 6 ++++++
1 file changed, 6 insertions(+)
diff --git a/tools/perf/util/data-convert-json.c b/tools/perf/util/data-convert-json.c
index d9f805bf6fb0..b0aaa23659a0 100644
--- a/tools/perf/util/data-convert-json.c
+++ b/tools/perf/util/data-convert-json.c
@@ -326,6 +326,10 @@ int bt_convert__perf2json(const char *input_name, const char *output_name,
.force = opts->force,
};
+ struct itrace_synth_opts itrace_synth_opts = {
+ .set = 0,
+ };
+
perf_tool__init(&c.tool, /*ordered_events=*/true);
c.tool.sample = process_sample_event;
c.tool.mmap = perf_event__process_mmap;
@@ -377,6 +381,8 @@ int bt_convert__perf2json(const char *input_name, const char *output_name,
goto err_fclose;
}
+ session->itrace_synth_opts = &itrace_synth_opts;
+
if (symbol__init(&session->header.env) < 0) {
fprintf(stderr, "Symbol init error!\n");
goto err_session_delete;
--
2.49.0
next reply other threads:[~2025-04-07 16:23 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-04-07 16:22 James O. D. Hunt [this message]
2025-04-17 6:25 ` Adrian Hunter
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=20250407162211.172951-1-james.o.hunt@intel.com \
--to=james.o.hunt@intel.com \
--cc=acme@kernel.org \
--cc=adrian.hunter@intel.com \
--cc=alexander.shishkin@linux.intel.com \
--cc=irogers@google.com \
--cc=jolsa@kernel.org \
--cc=kan.liang@linux.intel.com \
--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 \
/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
all inboxes | Powered by JetHome®