* [PATCH] perf/test: perf test case Daemon operations dumps core
@ 2023-06-27 9:26 Thomas Richter
2023-06-27 15:35 ` Namhyung Kim
0 siblings, 1 reply; 3+ messages in thread
From: Thomas Richter @ 2023-06-27 9:26 UTC (permalink / raw)
To: linux-kernel, linux-perf-users, acme, irogers, hca
Cc: svens, gor, sumanthk, Thomas Richter
The perf test case Daemon operations dumps core all the time.
I narrowed it down to this invocation:
Segmentation fault (core dumped)
....
(gdb) where
at builtin-daemon.c:1527
argv=0x3ffe66f9630) at perf.c:323
at perf.c:377
at perf.c:421
(gdb)
Normally this goes unnoticed, the core dumps are only shown in
verbose mode and when core dump generation is enabled on fedora 38:
# ./perf test daemon
80: daemon operations : Ok
# ll core*
-rw------- 1 root root 3551232 Jun 27 10:08 core.4586
-rw------- 1 root root 3551232 Jun 27 10:08 core.4688
-rw------- 1 root root 3551232 Jun 27 10:08 core.4812
-rw------- 1 root root 3551232 Jun 27 10:08 core.4857
-rw------- 1 root root 3551232 Jun 27 10:08 core.4893
-rw------- 1 root root 3551232 Jun 27 10:08 core.4933
-rw------- 1 root root 3551232 Jun 27 10:08 core.4947
-rw------- 1 root root 3551232 Jun 27 10:08 core.4949
# ./perf test -v daemon
80: daemon operations :
--- start ---
test child forked, pid 4974
test daemon list
./tests/shell/daemon.sh: line 133: 4980 Segmentation fault \
(core dumped) perf daemon start --config ${config}
test daemon reconfig
./tests/shell/daemon.sh: line 133: 5082 Segmentation fault \
(core dumped) perf daemon start --config ${config}
test daemon stop
./tests/shell/daemon.sh: line 133: 5206 Segmentation fault \
(core dumped) perf daemon start --config ${config}
test daemon signal
./tests/shell/daemon.sh: line 133: 5250 Segmentation fault \
(core dumped) perf daemon start --config ${config}
signal 12 sent to session 'test [5252]'
signal 12 sent to session 'test [5252]'
test daemon ping
./tests/shell/daemon.sh: line 133: 5286 Segmentation fault \
(core dumped) perf daemon start --config ${config}
test daemon lock
./tests/shell/daemon.sh: line 133: 5326 Segmentation fault \
(core dumped) perf daemon start --config ${config}
test child finished with 0
---- end ----
daemon operations: Ok
# ll core*|wc -l
16
#
The root cause is in function cmd_daemon():
argc = parse_options(argc, argv, daemon_options, daemon_usage,
PARSE_OPT_STOP_AT_NON_OPTION);
if (argc) {
if (!strcmp(argv[0], "start"))
ret = __cmd_start(&__daemon, daemon_options, argc,
argv);
if (!strcmp(argv[0], "signal"))
^^^^^^^
Parameter argv[0] is set to NULL in function __cmd_start() and the
next strcmp() accesses a NULL pointer.
Output after:
# ./perf daemon start --config /tmp/perf-daemon-config
#
# ./perf test -v daemon
80: daemon operations :
--- start ---
test child forked, pid 6517
test daemon list
test daemon reconfig
test daemon stop
test daemon signal
signal 12 sent to session 'test [6780]'
signal 12 sent to session 'test [6780]'
test daemon ping
test daemon lock
test child finished with 0
---- end ----
daemon operations: Ok
#
Fixes: 92294b906e6c ("perf daemon: Dynamically allocate path to perf")
Signed-off-by: Thomas Richter <tmricht@linux.ibm.com>
---
tools/perf/builtin-daemon.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/tools/perf/builtin-daemon.c b/tools/perf/builtin-daemon.c
index f5674d824a40..83954af36753 100644
--- a/tools/perf/builtin-daemon.c
+++ b/tools/perf/builtin-daemon.c
@@ -1524,7 +1524,7 @@ int cmd_daemon(int argc, const char **argv)
if (argc) {
if (!strcmp(argv[0], "start"))
ret = __cmd_start(&__daemon, daemon_options, argc, argv);
- if (!strcmp(argv[0], "signal"))
+ else if (!strcmp(argv[0], "signal"))
ret = __cmd_signal(&__daemon, daemon_options, argc, argv);
else if (!strcmp(argv[0], "stop"))
ret = __cmd_stop(&__daemon, daemon_options, argc, argv);
--
2.41.0
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] perf/test: perf test case Daemon operations dumps core
2023-06-27 9:26 [PATCH] perf/test: perf test case Daemon operations dumps core Thomas Richter
@ 2023-06-27 15:35 ` Namhyung Kim
2023-06-28 6:04 ` Thomas Richter
0 siblings, 1 reply; 3+ messages in thread
From: Namhyung Kim @ 2023-06-27 15:35 UTC (permalink / raw)
To: Thomas Richter
Cc: linux-kernel, linux-perf-users, acme, irogers, hca, svens, gor,
sumanthk
Hello,
On Tue, Jun 27, 2023 at 2:39 AM Thomas Richter <tmricht@linux.ibm.com> wrote:
>
> The perf test case Daemon operations dumps core all the time.
> I narrowed it down to this invocation:
Jiri sent the same fix already. I'll add your Reported-by, ok?
https://lore.kernel.org/all/20230626201606.2514679-1-jolsa@kernel.org/
Thanks,
Namhyung
>
> Segmentation fault (core dumped)
> ....
> (gdb) where
> at builtin-daemon.c:1527
> argv=0x3ffe66f9630) at perf.c:323
> at perf.c:377
> at perf.c:421
> (gdb)
>
> Normally this goes unnoticed, the core dumps are only shown in
> verbose mode and when core dump generation is enabled on fedora 38:
>
> # ./perf test daemon
> 80: daemon operations : Ok
> # ll core*
> -rw------- 1 root root 3551232 Jun 27 10:08 core.4586
> -rw------- 1 root root 3551232 Jun 27 10:08 core.4688
> -rw------- 1 root root 3551232 Jun 27 10:08 core.4812
> -rw------- 1 root root 3551232 Jun 27 10:08 core.4857
> -rw------- 1 root root 3551232 Jun 27 10:08 core.4893
> -rw------- 1 root root 3551232 Jun 27 10:08 core.4933
> -rw------- 1 root root 3551232 Jun 27 10:08 core.4947
> -rw------- 1 root root 3551232 Jun 27 10:08 core.4949
> # ./perf test -v daemon
> 80: daemon operations :
> --- start ---
> test child forked, pid 4974
> test daemon list
> ./tests/shell/daemon.sh: line 133: 4980 Segmentation fault \
> (core dumped) perf daemon start --config ${config}
> test daemon reconfig
> ./tests/shell/daemon.sh: line 133: 5082 Segmentation fault \
> (core dumped) perf daemon start --config ${config}
> test daemon stop
> ./tests/shell/daemon.sh: line 133: 5206 Segmentation fault \
> (core dumped) perf daemon start --config ${config}
> test daemon signal
> ./tests/shell/daemon.sh: line 133: 5250 Segmentation fault \
> (core dumped) perf daemon start --config ${config}
> signal 12 sent to session 'test [5252]'
> signal 12 sent to session 'test [5252]'
> test daemon ping
> ./tests/shell/daemon.sh: line 133: 5286 Segmentation fault \
> (core dumped) perf daemon start --config ${config}
> test daemon lock
> ./tests/shell/daemon.sh: line 133: 5326 Segmentation fault \
> (core dumped) perf daemon start --config ${config}
> test child finished with 0
> ---- end ----
> daemon operations: Ok
> # ll core*|wc -l
> 16
> #
>
> The root cause is in function cmd_daemon():
>
> argc = parse_options(argc, argv, daemon_options, daemon_usage,
> PARSE_OPT_STOP_AT_NON_OPTION);
>
> if (argc) {
> if (!strcmp(argv[0], "start"))
> ret = __cmd_start(&__daemon, daemon_options, argc,
> argv);
> if (!strcmp(argv[0], "signal"))
> ^^^^^^^
> Parameter argv[0] is set to NULL in function __cmd_start() and the
> next strcmp() accesses a NULL pointer.
>
> Output after:
>
> # ./perf daemon start --config /tmp/perf-daemon-config
> #
> # ./perf test -v daemon
> 80: daemon operations :
> --- start ---
> test child forked, pid 6517
> test daemon list
> test daemon reconfig
> test daemon stop
> test daemon signal
> signal 12 sent to session 'test [6780]'
> signal 12 sent to session 'test [6780]'
> test daemon ping
> test daemon lock
> test child finished with 0
> ---- end ----
> daemon operations: Ok
> #
>
> Fixes: 92294b906e6c ("perf daemon: Dynamically allocate path to perf")
>
> Signed-off-by: Thomas Richter <tmricht@linux.ibm.com>
> ---
> tools/perf/builtin-daemon.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/tools/perf/builtin-daemon.c b/tools/perf/builtin-daemon.c
> index f5674d824a40..83954af36753 100644
> --- a/tools/perf/builtin-daemon.c
> +++ b/tools/perf/builtin-daemon.c
> @@ -1524,7 +1524,7 @@ int cmd_daemon(int argc, const char **argv)
> if (argc) {
> if (!strcmp(argv[0], "start"))
> ret = __cmd_start(&__daemon, daemon_options, argc, argv);
> - if (!strcmp(argv[0], "signal"))
> + else if (!strcmp(argv[0], "signal"))
> ret = __cmd_signal(&__daemon, daemon_options, argc, argv);
> else if (!strcmp(argv[0], "stop"))
> ret = __cmd_stop(&__daemon, daemon_options, argc, argv);
> --
> 2.41.0
>
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] perf/test: perf test case Daemon operations dumps core
2023-06-27 15:35 ` Namhyung Kim
@ 2023-06-28 6:04 ` Thomas Richter
0 siblings, 0 replies; 3+ messages in thread
From: Thomas Richter @ 2023-06-28 6:04 UTC (permalink / raw)
To: Namhyung Kim
Cc: linux-kernel, linux-perf-users, acme, irogers, hca, svens, gor,
sumanthk
On 6/27/23 17:35, Namhyung Kim wrote:
> Hello,
>
> On Tue, Jun 27, 2023 at 2:39 AM Thomas Richter <tmricht@linux.ibm.com> wrote:
>>
>> The perf test case Daemon operations dumps core all the time.
>> I narrowed it down to this invocation:
>
> Jiri sent the same fix already. I'll add your Reported-by, ok?
>
> https://lore.kernel.org/all/20230626201606.2514679-1-jolsa@kernel.org/
>
> Thanks,
> Namhyung
>
sure, fine with me.
--
Thomas Richter, Dept 3303, IBM s390 Linux Development, Boeblingen, Germany
--
Vorsitzender des Aufsichtsrats: Gregor Pillen
Geschäftsführung: David Faller
Sitz der Gesellschaft: Böblingen / Registergericht: Amtsgericht Stuttgart, HRB 243294
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2023-06-28 7:52 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-06-27 9:26 [PATCH] perf/test: perf test case Daemon operations dumps core Thomas Richter
2023-06-27 15:35 ` Namhyung Kim
2023-06-28 6:04 ` Thomas Richter
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).