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@xxxxxxxxxxx> Signed-off-by: Vincent Whitchurch <vincent.whitchurch@xxxxxxxx> --- 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