linux-trace-devel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v2] trace-cmd report: Avoid crash on unknown event
@ 2021-12-08 14:34 Vincent Whitchurch
  2021-12-08 14:45 ` Steven Rostedt
  0 siblings, 1 reply; 4+ messages in thread
From: Vincent Whitchurch @ 2021-12-08 14:34 UTC (permalink / raw)
  To: rostedt; +Cc: linux-trace-devel, kernel, Vincent Whitchurch

Do not segfault if the event cannot be found for some reason and
tep_find_event_by_record() returns NULL.

With this patch:

 kworker/u8:0-7 [003] 1.245773: sched_stat_runtime: comm=kworker/u8:...
[UNKNOWN EVENT][UNKNOWN EVENT] (NULL):               [UNKNOWN EVENT]
 kworker/u8:0-7 [003] 1.245776: sched_switch: kworker/u8:0:7 [120] W...

Suggested-by: Steven Rostedt (VMware) <rostedt@goodmis.org>
Signed-off-by: Vincent Whitchurch <vincent.whitchurch@axis.com>
---
 tracecmd/trace-read.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/tracecmd/trace-read.c b/tracecmd/trace-read.c
index 6f43c1d..df40b75 100644
--- a/tracecmd/trace-read.c
+++ b/tracecmd/trace-read.c
@@ -142,12 +142,13 @@ static struct trace_hash wakeup_hash;
 static void print_event_name(struct trace_seq *s, struct tep_event *event)
 {
 	static const char *spaces = "                    "; /* 20 spaces */
+	const char *name = event ? event->name : "(NULL)";
 	int len;
 
-	trace_seq_printf(s, " %s: ", event->name);
+	trace_seq_printf(s, " %s: ", name);
 
 	/* Space out the event names evenly. */
-	len = strlen(event->name);
+	len = strlen(name);
 	if (len < 20)
 		trace_seq_printf(s, "%.*s", 20 - len, spaces);
 }
-- 
2.20.1


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH v2] trace-cmd report: Avoid crash on unknown event
  2021-12-08 14:34 [PATCH v2] trace-cmd report: Avoid crash on unknown event Vincent Whitchurch
@ 2021-12-08 14:45 ` Steven Rostedt
  2021-12-08 15:00   ` Vincent Whitchurch
  0 siblings, 1 reply; 4+ messages in thread
From: Steven Rostedt @ 2021-12-08 14:45 UTC (permalink / raw)
  To: Vincent Whitchurch; +Cc: linux-trace-devel, kernel

On Wed, 8 Dec 2021 15:34:02 +0100
Vincent Whitchurch <vincent.whitchurch@axis.com> wrote:

> Do not segfault if the event cannot be found for some reason and
> tep_find_event_by_record() returns NULL.
> 
> With this patch:
> 
>  kworker/u8:0-7 [003] 1.245773: sched_stat_runtime: comm=kworker/u8:...
> [UNKNOWN EVENT][UNKNOWN EVENT] (NULL):               [UNKNOWN EVENT]
>  kworker/u8:0-7 [003] 1.245776: sched_switch: kworker/u8:0:7 [120] W...
> 
> Suggested-by: Steven Rostedt (VMware) <rostedt@goodmis.org>
> Signed-off-by: Vincent Whitchurch <vincent.whitchurch@axis.com>

Hi Vincent,

I already applied the update.

  https://git.kernel.org/pub/scm/utils/trace-cmd/trace-cmd.git/commit/?id=196a3a63c466204f3e8f4fa35194fc9ab7cb1ab7

Sorry, I waited a bit but your reply sounded like you wanted me to do it.

-- Steve

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH v2] trace-cmd report: Avoid crash on unknown event
  2021-12-08 14:45 ` Steven Rostedt
@ 2021-12-08 15:00   ` Vincent Whitchurch
  2021-12-08 15:07     ` Steven Rostedt
  0 siblings, 1 reply; 4+ messages in thread
From: Vincent Whitchurch @ 2021-12-08 15:00 UTC (permalink / raw)
  To: Steven Rostedt; +Cc: linux-trace-devel@vger.kernel.org, kernel

On Wed, Dec 08, 2021 at 03:45:11PM +0100, Steven Rostedt wrote:
> On Wed, 8 Dec 2021 15:34:02 +0100
> Vincent Whitchurch <vincent.whitchurch@axis.com> wrote:
> 
> > Do not segfault if the event cannot be found for some reason and
> > tep_find_event_by_record() returns NULL.
> > 
> > With this patch:
> > 
> >  kworker/u8:0-7 [003] 1.245773: sched_stat_runtime: comm=kworker/u8:...
> > [UNKNOWN EVENT][UNKNOWN EVENT] (NULL):               [UNKNOWN EVENT]
> >  kworker/u8:0-7 [003] 1.245776: sched_switch: kworker/u8:0:7 [120] W...
> > 
> > Suggested-by: Steven Rostedt (VMware) <rostedt@goodmis.org>
> > Signed-off-by: Vincent Whitchurch <vincent.whitchurch@axis.com>
> 
> Hi Vincent,
> 
> I already applied the update.
> 
>   https://git.kernel.org/pub/scm/utils/trace-cmd/trace-cmd.git/commit/?id=196a3a63c466204f3e8f4fa35194fc9ab7cb1ab7
> 
> Sorry, I waited a bit but your reply sounded like you wanted me to do it.

No worries, thanks.  I did think it would be easier for you to commit
it.  I pulled before reworking the patch but I didn't see your commit.
It turns out I was using a clone from the following (wrong) git which
hasn't been updated in months...

 https://git.kernel.org/pub/scm/linux/kernel/git/rostedt/trace-cmd.git/

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH v2] trace-cmd report: Avoid crash on unknown event
  2021-12-08 15:00   ` Vincent Whitchurch
@ 2021-12-08 15:07     ` Steven Rostedt
  0 siblings, 0 replies; 4+ messages in thread
From: Steven Rostedt @ 2021-12-08 15:07 UTC (permalink / raw)
  To: Vincent Whitchurch; +Cc: linux-trace-devel@vger.kernel.org, kernel

On Wed, 8 Dec 2021 16:00:05 +0100
Vincent Whitchurch <vincent.whitchurch@axis.com> wrote:

> No worries, thanks.  I did think it would be easier for you to commit
> it.  I pulled before reworking the patch but I didn't see your commit.
> It turns out I was using a clone from the following (wrong) git which
> hasn't been updated in months...
> 
>  https://git.kernel.org/pub/scm/linux/kernel/git/rostedt/trace-cmd.git/

Ug, I try to keep that one up to date. I have three repos for trace-cmd and
two for libtracefs and libtraceevent (kernel.org and github). I've been
focused on the libraries for some time, and after updating trace-cmd, I
was thinking to myself "Hmm, isn't there another repo I update?"

I'll go and update that one too :-/

-- Steve

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2021-12-08 15:07 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2021-12-08 14:34 [PATCH v2] trace-cmd report: Avoid crash on unknown event Vincent Whitchurch
2021-12-08 14:45 ` Steven Rostedt
2021-12-08 15:00   ` Vincent Whitchurch
2021-12-08 15:07     ` Steven Rostedt

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).