Re: [PATCH v2] coredump: add %i/%I in core_pattern to report the tid of the crashed thread

From: Martin Milata
Date: Wed Sep 24 2014 - 05:12:28 EST

On Tue, Sep 23, 2014 at 16:05:51 -0700, Andrew Morton wrote:
> On Mon, 22 Sep 2014 19:15:25 +0200 Oleg Nesterov <oleg@xxxxxxxxxx> wrote:
> > format_corename() can only pass the leader's pid to the core handler, but
> > there is no simple way to figure out which thread originated the coredump.
> >
> > As Jan explains, this also means that there is no simple way to create the
> > backtrace of the crashed process:
> >
> > As programs are mostly compiled with implicit gcc -fomit-frame-pointer one
> > needs program's .eh_frame section (equivalently PT_GNU_EH_FRAME segment) or
> > .debug_frame section. .debug_frame usually is present only in separate debug
> > info files usually not even installed on the system. While .eh_frame is a
> > part of the executable/library (and it is even always mapped for C++
> > exceptions unwinding) it no longer has to be present anywhere on the disk
> > as the program could be upgraded in the meantime and the running instance
> > has its executable file already unlinked from disk.
> >
> > One possibility is to echo 0x3f >/proc/*/coredump_filter and dump all the
> > file-backed memory including the executable's .eh_frame section. But that
> > can create huge core files, for example even due to mmapped data files.
> >
> > Other possibility would be to read .eh_frame from /proc/PID/mem at the
> > core_pattern handler time of the core dump. For the backtrace one needs to
> > read the register state first which can be done from core_pattern handler:
> >
> > close(0); // close pipe fd to resume the sleeping dumper
> > waitpid(); // should report EXIT
> > PTRACE_GETREGS or other requests
> >
> > The remaining problem is how to get the 'tid' value of the crashed thread.
> > It could be read from the first NT_PRSTATUS note of the core file but that
> > makes the core_pattern handler complicated.
> >
> > Unfortunately %t is already used so this patch uses %i/%I.
> Is any userspace actually going to use this? If so, details?
> Am wondering what is driving this change...

Automatic Bug Reporting Tool [1] is experimenting with this. It is using
elfutils [2] unwinder for generating the backtraces. Apart from not
needing matching executables as mentioned above, another advantage is
that we can get the backtrace without saving the core (which might be
quite large) to disk.

To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at
Please read the FAQ at