[Patch, libfortran] PR 48931 Async-signal-safety of backtrace signal handler
Janne Blomqvist
blomqvist.janne@gmail.com
Sun May 15 17:43:00 GMT 2011
On Sat, May 14, 2011 at 22:40, Janne Blomqvist
<blomqvist.janne@gmail.com> wrote:
> Hi
>
> the current version of showing the backtrace is not async-signal-safe
> as it uses backtrace_symbols() which, in turn, uses malloc(). The
> attached patch changes the backtrace printing functionality to instead
> use backtrace_symbols_fd() and pipes.
>
> Also, it does some other work on backtrace printing:
>
> - Nowadays the main program has the same debug symbol name as whatever
> the name of the main program is, rather than MAIN__. Therefore remove
> special case logic related to that.
FWIW, I noticed that if debug symbols are not included, the MAIN__ is
printed. So should I add back the special casing of MAIN__?
> - Don't filter out stack frames from inside libgfortran, as this might
> lose information in case the reason for the crash is in the library.
>
> - Reformat the output slightly, so the each stack frame fits on one
> line, and begins with #NUM, similar to GDB.
I reformatted it some more, now it includes the file name, so the output is like
Backtrace for this error:
#0 /home/janne/src/gfortran/trunk/install/lib64/libgfortran.so.3(+0x18357)[0x7fd385e51357]
#1 /home/janne/src/gfortran/trunk/install/lib64/libgfortran.so.3(+0x19de7)[0x7fd385e52de7]
#2 /home/janne/src/gfortran/trunk/install/lib64/libgfortran.so.3(+0xe1f69)[0x7fd385f1af69]
#3 /home/janne/src/gfortran/my-patches/pr48931-backtrace-abort/a.out[0x400612]
in b_ at bt.f90:5
#4 /home/janne/src/gfortran/my-patches/pr48931-backtrace-abort/a.out[0x400620]
in b_ at bt.f90:7
#5 /home/janne/src/gfortran/my-patches/pr48931-backtrace-abort/a.out[0x400630]
in a_ at bt.f90:11
#6 /home/janne/src/gfortran/my-patches/pr48931-backtrace-abort/a.out[0x400640]
in bt at bt.f90:15
Aborted
Similar to GDB, the address is now printed before function and
file:line number info. And similar to backtrace_symbols_fd() output (3
first stack frames above), the file name is printed before the
address.
I also improved the logic for figuring out the executable path, as the
old way doesn't work if the executable is not in the current working
directory. The improved logic is, I believe, Linux-specific, but
since the only user of full_exe_path() is the glibc-specific
backtracing stuff I don't think that is a big loss.
Regtested on x86_64-unknown-linux-gnu, Ok for trunk?
2011-05-15 Janne Blomqvist <jb@gcc.gnu.org>
PR libfortran/48931
* configure.ac: Check for backtrace_symbols_fd instead of
backtrace_symbols, check for readlink.
* config.h.in: Regenerated.
* configure: Regenerated.
* runtime/backtrace.c (local_strcasestr): Remove.
(bt_header): New function.
(dump_glibc_backtrace): Remove.
(show_backtrace): Rework to use backtrace_symbols_fd and pipes,
reformat output.
* runtime/main.c (store_exe_path): Try to check /proc/self/exe
first.
(full_exe_path): If the path is NULL, try to figure it out before
returning.
--
Janne Blomqvist
-------------- next part --------------
A non-text attachment was scrubbed...
Name: bt2.diff
Type: text/x-patch
Size: 11760 bytes
Desc: not available
URL: <http://gcc.gnu.org/pipermail/gcc-patches/attachments/20110515/53ac9ff8/attachment.bin>
More information about the Gcc-patches
mailing list