Skip to content

Commit

Permalink
dump: Skip kernel function records for unrelated tasks
Browse files Browse the repository at this point in the history
I found that sometimes the kernel ftrace data contains record from
unrelated tasks even if it has the task filter.  In that case it cannot
get a valid task pointer and result in a segfault due to the NULL
dereference.  Maybe it's a bug in the kernel, but we should be able to
run uftrace without a problem.

Reported-by: George Xanthakis <georgexanthak@gmail.com>
Signed-off-by: Namhyung Kim <namhyung@gmail.com>
  • Loading branch information
namhyung committed Jun 9, 2024
1 parent b52b0fd commit 7791257
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions cmds/dump.c
Original file line number Diff line number Diff line change
Expand Up @@ -950,6 +950,8 @@ static void dump_chrome_kernel_rstack(struct uftrace_dump_ops *ops,

tid = kernel->tids[cpu];
task = get_task_handle(kernel->handle, tid);
if (task == NULL)
return;

dump_chrome_task_rstack(ops, task, name);
}
Expand Down Expand Up @@ -1152,6 +1154,8 @@ static void dump_flame_kernel_rstack(struct uftrace_dump_ops *ops,

tid = kernel->tids[cpu];
task = get_task_handle(kernel->handle, tid);
if (task == NULL)
return;

graph = graph_get_task(task, sizeof(*graph));

Expand Down Expand Up @@ -1223,6 +1227,8 @@ static void dump_graphviz_kernel_rstack(struct uftrace_dump_ops *ops,

tid = kernel->tids[cpu];
task = get_task_handle(kernel->handle, tid);
if (task == NULL)
return;

graph = graph_get_task(task, sizeof(*graph));

Expand Down Expand Up @@ -1299,6 +1305,8 @@ static void dump_mermaid_kernel_rstack(struct uftrace_dump_ops *ops,

tid = kernel->tids[cpu];
task = get_task_handle(kernel->handle, tid);
if (task == NULL)
return;

graph = graph_get_task(task, sizeof(*graph));

Expand Down

0 comments on commit 7791257

Please sign in to comment.