perf command line error handling regression
Ian,
Since the commit below, I see the following:
$ perf foo Segmentation fault (core dumped) $
Before:
$ perf foo perf: 'foo' is not a perf-command. See 'perf --help'. $
(gdb) bt
#0 0x00007ffff6f89fe2 in __strcmp_evex () from /lib64/libc.so.6 #1 0x00007ffff6e6387d in msort_with_tmp.part () from /lib64/libc.so.6 #2 0x00007ffff6e63bd6 in qsort_r () from /lib64/libc.so.6 #3 0x00000000005895af in help_unknown_cmd (cmd=cmd@entry=0x7fffffffdaf2 "foo") at util/help-unknown-cmd.c:71 #4 0x000000000040cb52 in main (argc=1, argv=0x7fffffffd750) at perf.c:543
commit 657a3efee43a29d13c4f30e4c8f6a178fd2bf14a
Author: Ian Rogers <[email protected]> Date: Sun Jun 11 16:36:06 2023 -0700
lib subcmd: Avoid memory leak in exclude_cmds
exclude_cmds will shorten the cmds names array, before doing so free the removed entry.
Quoted 23 lines · Andi Kleen
Ian,
Since the commit below, I see the following:
$ perf foo Segmentation fault (core dumped) $Before:
$ perf foo perf: 'foo' is not a perf-command. See 'perf --help'. $(gdb) bt
#0 0x00007ffff6f89fe2 in __strcmp_evex () from /lib64/libc.so.6 #1 0x00007ffff6e6387d in msort_with_tmp.part () from /lib64/libc.so.6 #2 0x00007ffff6e63bd6 in qsort_r () from /lib64/libc.so.6 #3 0x00000000005895af in help_unknown_cmd (cmd=cmd@entry=0x7fffffffdaf2 "foo") at util/help-unknown-cmd.c:71 #4 0x000000000040cb52 in main (argc=1, argv=0x7fffffffd750) at perf.c:543
Quoted 8 lines
commit
657a3efee43a29d13c4f30e4c8f6a178fd2bf14aAuthor: Ian Rogers <[email protected]> Date: Sun Jun 11 16:36:06 2023 -0700lib subcmd: Avoid memory leak in
exclude_cmds
exclude_cmdswill shorten the cmds names array, before doing so free the removed entry.
Thanks Andi, this was also reported by Anup in the office hours.
The regression is fixed by:
https://lore.kernel.org/lkml/[email protected]/
which is already merged and should merge through to other trees.
Thanks,
Ian