From: Thomas Richter <tmricht@linux.ibm.com>
To: linux-kernel@vger.kernel.org, linux-perf-users@vger.kernel.org,
acme@kernel.org, irogers@google.com, hca@linux.ibm.com
Cc: svens@linux.ibm.com, gor@linux.ibm.com, sumanthk@linux.ibm.com,
Thomas Richter <tmricht@linux.ibm.com>
Subject: [PATCH] perf/test: perf test case Daemon operations dumps core
Date: Tue, 27 Jun 2023 11:26:33 +0200 [thread overview]
Message-ID: <20230627092633.2135105-1-tmricht@linux.ibm.com> (raw)
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
next reply other threads:[~2023-06-27 9:26 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-06-27 9:26 Thomas Richter [this message]
2023-06-27 15:35 ` [PATCH] perf/test: perf test case Daemon operations dumps core Namhyung Kim
2023-06-28 6:04 ` Thomas Richter
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=20230627092633.2135105-1-tmricht@linux.ibm.com \
--to=tmricht@linux.ibm.com \
--cc=acme@kernel.org \
--cc=gor@linux.ibm.com \
--cc=hca@linux.ibm.com \
--cc=irogers@google.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-perf-users@vger.kernel.org \
--cc=sumanthk@linux.ibm.com \
--cc=svens@linux.ibm.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 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).