Re: Suggestions on how to debug kernel crashes where printk and gdb both does not work

From: Pavel Skripkin
Date: Mon Jun 14 2021 - 09:34:26 EST


On Mon, 14 Jun 2021 21:22:43 +0800
Dongliang Mu <mudongliangabcd@xxxxxxxxx> wrote:

> Dear kernel developers,
>
> I was trying to debug the crash - memory leak in hwsim_add_one [1]
> recently. However, I encountered a disgusting issue: my breakpoint and
> printk/pr_alert in the functions that will be surely executed do not
> work. The stack trace is in the following. I wrote this email to ask
> for some suggestions on how to debug such cases?
>
> Thanks very much. Looking forward to your reply.
>

Hi, Dongliang!

This bug is not similar to others on the dashboard. I spent some time
debugging it a week ago. The main problem here, that memory
allocation happens in the boot time:

> [<ffffffff84359255>] kernel_init+0xc/0x1a7 init/main.c:1447

and reproducer simply tries to
free this data. You can use ftrace to look at it. Smth like this:

$ echo 'hwsim_*' > $TRACE_DIR/set_ftrace_filter

would work.


With regards,
Pavel Skripkin