aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSteven Rostedt (VMware) <rostedt@goodmis.org>2021-05-07 09:38:48 -0400
committerYordan Karadzhov (VMware) <y.karadz@gmail.com>2021-05-14 14:26:50 +0300
commit0a04671bb8dd09f3dd1ddb88333b130fb3324400 (patch)
treeb8ef925840aab10f34109b2deb3c93ead6a3a8d8
parent358d1ca58264f861f59ed981ec75c4224657a5d4 (diff)
downloadkernel-shark-0a04671bb8dd09f3dd1ddb88333b130fb3324400.tar.gz
kernel-shark: Add check for return of ksmodel_get_cpu_front()
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. Link: https://lore.kernel.org/linux-trace-devel/20210507093848.72bf0bed@gandalf.local.home Signed-off-by: Steven Rostedt (VMware) <rostedt@goodmis.org>
-rw-r--r--src/KsPlotTools.cpp2
1 files changed, 1 insertions, 1 deletions
diff --git a/src/KsPlotTools.cpp b/src/KsPlotTools.cpp
index 225dc341..abef5f87 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,