Re: [PATCH v3 10/10] perf list: Add json output option
From: Arnaldo Carvalho de Melo
Date: Wed Nov 16 2022 - 06:49:39 EST
Em Wed, Nov 16, 2022 at 08:23:07AM -0300, Arnaldo Carvalho de Melo escreveu:
> Em Tue, Nov 15, 2022 at 10:44:54AM -0300, Arnaldo Carvalho de Melo escreveu:
> > Em Mon, Nov 14, 2022 at 01:07:23PM -0800, Ian Rogers escreveu:
> > > Output events and metrics in a json format by overriding the print
> > > callbacks. Currently other command line options aren't supported and
> > > metrics are repeated once per metric group.
> >
> > Applied the patch with a few fixes and added this to the last cset:
>
> There is a problem, detected using 'perf test', the last one:
>
> [root@quaco ~]# perf test "trace + vfs_getname"
> 112: Check open filename arg using perf trace + vfs_getname : FAILED!
> [root@quaco ~]# perf test -v "trace + vfs_getname"
> 112: Check open filename arg using perf trace + vfs_getname :
> --- start ---
> test child forked, pid 611667
> test child finished with -1
> ---- end ----
> Check open filename arg using perf trace + vfs_getname: FAILED!
> [root@quaco ~]#
>
> Verbose didn't help, so I looked at the shell script for that test and
> the problem is here:
>
> [root@quaco ~]# perf list syscalls:sys_enter_open*
> Segmentation fault (core dumped)
> ^C
> [root@quaco ~]#
> [root@quaco ~]#
> [root@quaco ~]# gdb perf
> GNU gdb (GDB) Fedora 12.1-2.fc36
> (gdb) run list syscalls:sys_enter_open*
> Starting program: /root/bin/perf list syscalls:sys_enter_open*
> [Thread debugging using libthread_db enabled]
> Using host libthread_db library "/lib64/libthread_db.so.1".
> [Detaching after fork from child process 611757]
>
> Program received signal SIGSEGV, Segmentation fault.
> 0x00000000004e742b in __match_glob (str=0x0, pat=0xe44900 "syscalls", ignore_space=ignore_space@entry=false, case_ins=case_ins@entry=false) at util/string.c:113
> 113 while (*str && *pat && *pat != '*') {
> Missing separate debuginfos, use: dnf debuginfo-install bzip2-libs-1.0.8-11.fc36.x86_64 cyrus-sasl-lib-2.1.27-18.fc36.x86_64 elfutils-debuginfod-client-0.187-4.fc36.x86_64 elfutils-libelf-0.187-4.fc36.x86_64 elfutils-libs-0.187-4.fc36.x86_64 glib2-2.72.3-1.fc36.x86_64 glibc-2.35-20.fc36.x86_64 keyutils-libs-1.6.1-4.fc36.x86_64 krb5-libs-1.19.2-11.fc36.x86_64 libbabeltrace-1.5.8-9.fc36.x86_64 libbrotli-1.0.9-7.fc36.x86_64 libcap-2.48-4.fc36.x86_64 libcom_err-1.46.5-2.fc36.x86_64 libcurl-7.82.0-8.fc36.x86_64 libevent-2.1.12-6.fc36.x86_64 libgcc-12.2.1-2.fc36.x86_64 libidn2-2.3.4-1.fc36.x86_64 libnghttp2-1.46.0-2.fc36.x86_64 libpsl-0.21.1-5.fc36.x86_64 libselinux-3.3-4.fc36.x86_64 libssh-0.9.6-4.fc36.x86_64 libunistring-1.0-1.fc36.x86_64 libunwind-1.6.2-2.fc36.x86_64 libuuid-2.38-1.fc36.x86_64 libxcrypt-4.4.28-1.fc36.x86_64 libzstd-1.5.2-2.fc36.x86_64 numactl-libs-2.0.14-5.fc36.x86_64 openldap-2.6.3-1.fc36.x86_64 openssl-libs-3.0.5-1.fc36.x86_64 pcre-8.45-1.fc36.1.x86_64 perl-libs-5.34.1-486.fc36.x86_64 popt-1.18-7.fc36.x86_64 python3-libs-3.10.7-1.fc36.x86_64 slang-2.3.2-11.fc36.x86_64 xz-libs-5.2.5-9.fc36.x86_64 zlib-1.2.11-33.fc36.x86_64
> (gdb) bt
> #0 0x00000000004e742b in __match_glob (str=0x0, pat=0xe44900 "syscalls", ignore_space=ignore_space@entry=false, case_ins=case_ins@entry=false) at util/string.c:113
> #1 0x00000000004e7830 in strglobmatch (str=<optimized out>, pat=<optimized out>) at util/string.c:172
> #2 0x00000000004241ea in default_print_event (ps=0x7fffffffd370, pmu_name=<optimized out>, topic=0x0, event_name=0x7fffffffc2d0 "alarmtimer:alarmtimer_cancel", event_alias=0x0, scale_unit=<optimized out>, deprecated=<optimized out>, event_type_desc=<optimized out>,
> desc=<optimized out>, long_desc=<optimized out>, encoding_desc=<optimized out>, metric_name=<optimized out>, metric_expr=<optimized out>) at builtin-list.c:107
> #3 0x00000000004e3224 in print_tracepoint_events (print_cb=print_cb@entry=0x7fffffffd350, print_state=0x7fffffffd370) at util/print-events.c:94
> #4 0x0000000000425342 in cmd_list (argc=<optimized out>, argv=<optimized out>) at builtin-list.c:521
> #5 0x00000000004b4579 in run_builtin (p=p@entry=0xdb0490 <commands+240>, argc=argc@entry=2, argv=argv@entry=0x7fffffffdbb0) at perf.c:322
> #6 0x000000000040f506 in handle_internal_command (argv=<optimized out>, argc=<optimized out>) at perf.c:376
> #7 run_argv (argv=<optimized out>, argcp=<optimized out>) at perf.c:420
> #8 main (argc=2, argv=0x7fffffffdbb0) at perf.c:550
> (gdb)
>
> Trying to fix this now.
>
> Please always run 'perf test' before and after your patches and before
> sending it upstream.
Running as !root on a different machine I get some other interesting
info:
⬢[acme@toolbox perf]$ perf list syscalls:sys_enter_open*
double free or corruption (fasttop)
Aborted (core dumped)
⬢[acme@toolbox perf]$
That is:
free(ps.pmu_glob);
at the end of cmd_list().
- Arnaldo