From: Steven Rostedt <rostedt@goodmis.org>
To: Yordan Karadzhov <y.karadz@gmail.com>
Cc: Linux Trace Devel <linux-trace-devel@vger.kernel.org>
Subject: [PATCH] kernel-shark: Add check for return of ksmodel_get_cpu_front()
Date: Fri, 7 May 2021 09:38:48 -0400 [thread overview]
Message-ID: <20210507093848.72bf0bed@gandalf.local.home> (raw)
From: Steven Rostedt (VMware) <rostedt@goodmis.org>
When I loaded two trace.dat files (host and guest), but the mapping of
which host thread is associated to which guest vCPU was missing from the
file, it caused a SEGFAULT. That's because in fillTaskGraph(), the
lamGetPidCPU() calls ksmodule_get_cpu_front() which returns a negative
number and does not set index. But the next line checks data[index] where
index is some random number, and the application crashes.
By checking the return of ksmodule_get_cpu_front(), and if it is negative
do not reference data[index] and just let eFront be nullptr, the
application shows no mapping, but at least it does not crash.
Signed-off-by: Steven Rostedt (VMware) <rostedt@goodmis.org>
---
You can reproduce this with:
http://rostedt.org/private/trace-no-map.tar.bz2
diff --git a/src/KsPlotTools.cpp b/src/KsPlotTools.cpp
index 225dc34..abef5f8 100644
--- a/src/KsPlotTools.cpp
+++ b/src/KsPlotTools.cpp
@@ -1280,7 +1280,7 @@ void Graph::fillTaskGraph(int sd, int pid)
false,
_collectionPtr,
&index);
- if (index >= 0)
+ if (cpuFront >= 0 && index >= 0)
eFront = _histoPtr->data[index];
cpuBack = ksmodel_get_cpu_back(_histoPtr, bin,
next reply other threads:[~2021-05-07 13:38 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-05-07 13:38 Steven Rostedt [this message]
2021-05-11 13:25 ` [PATCH] kernel-shark: Add check for return of ksmodel_get_cpu_front() Yordan Karadzhov
2021-05-11 13:40 ` Steven Rostedt
2021-05-11 13:51 ` Yordan Karadzhov
2021-05-14 11:50 ` Yordan Karadzhov
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=20210507093848.72bf0bed@gandalf.local.home \
--to=rostedt@goodmis.org \
--cc=linux-trace-devel@vger.kernel.org \
--cc=y.karadz@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 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).