All of lore.kernel.org
 help / color / mirror / Atom feed
From: Arnaldo Carvalho de Melo <acme@kernel.org>
To: Adrian Hunter <adrian.hunter@intel.com>
Cc: Jiri Olsa <jolsa@redhat.com>,
	linux-kernel@vger.kernel.org,
	Riccardo Mancini <rickyman7@gmail.com>,
	Namhyung Kim <namhyung@kernel.org>
Subject: Re: [PATCH 1/2] perf inject: Fix segfault due to close without open
Date: Mon, 13 Dec 2021 10:11:59 -0300	[thread overview]
Message-ID: <YbdGn89u/HXXvfwo@kernel.org> (raw)
In-Reply-To: <20211213084829.114772-2-adrian.hunter@intel.com>

Em Mon, Dec 13, 2021 at 10:48:28AM +0200, Adrian Hunter escreveu:
> The fixed commit attempts to close inject.output even if it was never
> opened e.g.
> 
>  $ perf record uname
>  Linux
>  [ perf record: Woken up 1 times to write data ]
>  [ perf record: Captured and wrote 0.002 MB perf.data (7 samples) ]
>  $ perf inject -i perf.data --vm-time-correlation=dry-run
>  Segmentation fault (core dumped)
>  $ gdb --quiet perf
>  Reading symbols from perf...
>  (gdb) r inject -i perf.data --vm-time-correlation=dry-run
>  Starting program: /home/ahunter/bin/perf inject -i perf.data --vm-time-correlation=dry-run
>  [Thread debugging using libthread_db enabled]
>  Using host libthread_db library "/lib/x86_64-linux-gnu/libthread_db.so.1".

Thanks, applied.

- Arnaldo

 
>  Program received signal SIGSEGV, Segmentation fault.
>  0x00007eff8afeef5b in _IO_new_fclose (fp=0x0) at iofclose.c:48
>  48      iofclose.c: No such file or directory.
>  (gdb) bt
>  #0  0x00007eff8afeef5b in _IO_new_fclose (fp=0x0) at iofclose.c:48
>  #1  0x0000557fc7b74f92 in perf_data__close (data=data@entry=0x7ffcdafa6578) at util/data.c:376
>  #2  0x0000557fc7a6b807 in cmd_inject (argc=<optimized out>, argv=<optimized out>) at builtin-inject.c:1085
>  #3  0x0000557fc7ac4783 in run_builtin (p=0x557fc8074878 <commands+600>, argc=4, argv=0x7ffcdafb6a60) at perf.c:313
>  #4  0x0000557fc7a25d5c in handle_internal_command (argv=<optimized out>, argc=<optimized out>) at perf.c:365
>  #5  run_argv (argcp=<optimized out>, argv=<optimized out>) at perf.c:409
>  #6  main (argc=4, argv=0x7ffcdafb6a60) at perf.c:539
>  (gdb)
> 
> Fixes: 02e6246f5364d ("perf inject: Close inject.output on exit")
> Cc: stable@vger.kernel.org
> Signed-off-by: Adrian Hunter <adrian.hunter@intel.com>
> ---
>  tools/perf/builtin-inject.c | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
> 
> diff --git a/tools/perf/builtin-inject.c b/tools/perf/builtin-inject.c
> index b9d6306cc14e..af70f1c72052 100644
> --- a/tools/perf/builtin-inject.c
> +++ b/tools/perf/builtin-inject.c
> @@ -1078,7 +1078,8 @@ int cmd_inject(int argc, const char **argv)
>  	zstd_fini(&(inject.session->zstd_data));
>  	perf_session__delete(inject.session);
>  out_close_output:
> -	perf_data__close(&inject.output);
> +	if (!inject.in_place_update)
> +		perf_data__close(&inject.output);
>  	free(inject.itrace_synth_opts.vm_tm_corr_args);
>  	return ret;
>  }
> -- 
> 2.25.1

-- 

- Arnaldo

  reply	other threads:[~2021-12-13 13:12 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-12-13  8:48 [PATCH 0/2] perf inject: Fix segfaults relating to in-place update Adrian Hunter
2021-12-13  8:48 ` [PATCH 1/2] perf inject: Fix segfault due to close without open Adrian Hunter
2021-12-13 13:11   ` Arnaldo Carvalho de Melo [this message]
2021-12-13  8:48 ` [PATCH 2/2] perf inject: Fix segfault due to perf_data__fd() " Adrian Hunter
2021-12-13 13:13   ` Arnaldo Carvalho de Melo
2021-12-13 19:29     ` Namhyung Kim

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=YbdGn89u/HXXvfwo@kernel.org \
    --to=acme@kernel.org \
    --cc=adrian.hunter@intel.com \
    --cc=jolsa@redhat.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=namhyung@kernel.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.