Bug 48931 - Backtrace functionality not async-signal-safe
Summary: Backtrace functionality not async-signal-safe
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: libfortran (show other bugs)
Version: unknown
: P3 minor
Target Milestone: ---
Assignee: Janne Blomqvist
URL: http://gcc.gnu.org/ml/gcc-patches/201...
Keywords:
Depends on:
Blocks:
 
Reported: 2011-05-08 19:13 UTC by Janne Blomqvist
Modified: 2011-05-29 20:13 UTC (History)
0 users

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Janne Blomqvist 2011-05-08 19:13:40 UTC
When -fbacktrace is enabled, gfortran enables a signal handler for the common failure signals, and tries to print a backtrace in the handler. On Linux platforms this is accomplished with the glibc backtrace() and backtrace_symbols() functions. However, backtrace_symbols() uses malloc() to allocate memory and is hence not safe to use within a signal handler. 

It might be possible to instead use backtrace_symbols_fd() and output either directly to STDERR_FILENO, or to a pipe.
Comment 1 Janne Blomqvist 2011-05-14 15:15:56 UTC
Assigning to myself.
Comment 2 Janne Blomqvist 2011-05-15 09:38:56 UTC
Patch: http://gcc.gnu.org/ml/gcc-patches/2011-05/msg01058.html
Comment 3 Janne Blomqvist 2011-05-22 16:38:08 UTC
Author: jb
Date: Sun May 22 16:38:05 2011
New Revision: 174030

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=174030
Log:
PR 48931 Make backtrace async-signal-safe, reformat output

Modified:
    trunk/libgfortran/ChangeLog
    trunk/libgfortran/config.h.in
    trunk/libgfortran/configure
    trunk/libgfortran/configure.ac
    trunk/libgfortran/runtime/backtrace.c
    trunk/libgfortran/runtime/main.c
Comment 4 Janne Blomqvist 2011-05-22 16:41:16 UTC
Fixed, closing.
Comment 5 Janne Blomqvist 2011-05-29 20:13:56 UTC
Author: jb
Date: Sun May 29 20:13:52 2011
New Revision: 174415

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=174415
Log:
PR 48931 Use async-signal-safe execve instead of execvp

Modified:
    trunk/libgfortran/ChangeLog
    trunk/libgfortran/libgfortran.h
    trunk/libgfortran/runtime/backtrace.c
    trunk/libgfortran/runtime/compile_options.c
    trunk/libgfortran/runtime/main.c