trace-cmd report: Avoid crash on unknown event
PATCH v2 1/1 trace-cmd report: Avoid crash on unknown event
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...
--- tracecmd/trace-read.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
tracecmd/trace-read.c +3 -2
@@ -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); }
Signature · 1 line
2.20.1
Quoted 11 lines · On Wed, 8 Dec 2021 15:34:02 +0100 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) <[email protected]>Signed-off-by Vincent Whitchurch <[email protected]>
Hi Vincent,
I already applied the update.
Sorry, I waited a bit but your reply sounded like you wanted me to do it.
-- Steve
Quoted 15 lines · Steven Rostedt
Quoted 11 lines · On Wed, 8 Dec 2021 15:34:02 +0100 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) <[email protected]>Signed-off-by Vincent Whitchurch <[email protected]>
Quoted 7 lines
Hi Vincent,
I already applied the update.
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/
Quoted 6 lines · On Wed, 8 Dec 2021 16:00:05 +0100 Vincent Whitchurch…
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