From: Arnaldo Carvalho de Melo <acme@kernel.org>
To: Riccardo Mancini <rickyman7@gmail.com>
Cc: Namhyung Kim <namhyung@kernel.org>,
Ian Rogers <irogers@google.com>,
Peter Zijlstra <peterz@infradead.org>,
Ingo Molnar <mingo@redhat.com>,
Mark Rutland <mark.rutland@arm.com>,
Alexander Shishkin <alexander.shishkin@linux.intel.com>,
Jiri Olsa <jolsa@redhat.com>,
linux-perf-users@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] perf: fix segfault when wrong option for --debug is provided
Date: Tue, 1 Jun 2021 10:37:41 -0300 [thread overview]
Message-ID: <YLY4JfCmgaYGNBQO@kernel.org> (raw)
In-Reply-To: <20210531212828.240077-1-rickyman7@gmail.com>
Em Mon, May 31, 2021 at 11:28:28PM +0200, Riccardo Mancini escreveu:
> The command `perf --debug record` causes a segfault instead of notifying
> the user of the unrecognized option for --debug (the correct syntax would
> be `perf --debug verbose=2 record`).
>
> The bug is caused by a call to pr_err before debug_file (debug.c:34) is
> set via perf_debug_setup(). It has been introduced in
> commit 8abceacff87d ("perf debug: Add debug_set_file function").
>
> This patch resolves the bug by calling perf_debug_setup earlier in the
> main, so that debug_file is set to stderr before any call to a debug
> printing function is made.
Ian fixed this earlier and it is already even upstream:
https://git.kernel.org/torvalds/c/c59870e2110e1229a6e4
Thanks,
- Arnaldo
> Signed-off-by: Riccardo Mancini <rickyman7@gmail.com>
> ---
> tools/perf/perf.c | 3 +--
> 1 file changed, 1 insertion(+), 2 deletions(-)
>
> diff --git a/tools/perf/perf.c b/tools/perf/perf.c
> index 20cb91ef06ffc..cffbab2d085a7 100644
> --- a/tools/perf/perf.c
> +++ b/tools/perf/perf.c
> @@ -448,6 +448,7 @@ int main(int argc, const char **argv)
> pager_init(PERF_PAGER_ENVIRONMENT);
>
> libperf_init(libperf_print);
> + perf_debug_setup();
>
> cmd = extract_argv0_path(argv[0]);
> if (!cmd)
> @@ -531,8 +532,6 @@ int main(int argc, const char **argv)
> */
> pthread__block_sigwinch();
>
> - perf_debug_setup();
> -
> while (1) {
> static int done_help;
>
> --
> 2.23.0
>
--
- Arnaldo
prev parent reply other threads:[~2021-06-01 13:37 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-05-31 21:28 [PATCH] perf: fix segfault when wrong option for --debug is provided Riccardo Mancini
2021-06-01 13:37 ` Arnaldo Carvalho de Melo [this message]
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=YLY4JfCmgaYGNBQO@kernel.org \
--to=acme@kernel.org \
--cc=alexander.shishkin@linux.intel.com \
--cc=irogers@google.com \
--cc=jolsa@redhat.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 \
--cc=peterz@infradead.org \
--cc=rickyman7@gmail.com \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.