diff options
author | David Malcolm <dmalcolm@redhat.com> | 2024-11-05 18:30:39 -0500 |
---|---|---|
committer | David Malcolm <dmalcolm@redhat.com> | 2024-11-05 18:30:39 -0500 |
commit | 8c4184682d1cdfc43296f9550a48eaadb7501bbd (patch) | |
tree | 86ef08958dbe8d3bd8eb76d950458bc020dcd56d /gcc/cp | |
parent | 2e35fbd1fd1c8c149ce1156f4a2c15c9c331a1ca (diff) | |
download | gcc-8c4184682d1cdfc43296f9550a48eaadb7501bbd.zip gcc-8c4184682d1cdfc43296f9550a48eaadb7501bbd.tar.gz gcc-8c4184682d1cdfc43296f9550a48eaadb7501bbd.tar.bz2 |
fortran: dynamically allocate error_buffer [PR117442]
PR fortran/117442 reports a crash on exit of f951 when configured
with --enable-gather-detailed-mem-stats.
The crash happens if any diagnostics were ever buffered into
error_buffer. The root cause is that error_buffer is statically
allocated and thus has a non-trivial destructor called at exit.
If error_buffer's diagnostic_buffer ever buffered anything, then
a diagnostic_per_format_buffer will have been created for the
buffer per-output-sink, and the destructors for these call
into the mem-stats subsystem, which has already beeen cleaned up.
The simplest fix is to allocate error_buffer on the heap, rather
that statically, which fixes the crash.
There's a comment about error_buffer:
/* pp_error_buffer is statically allocated. This simplifies memory
management when using gfc_push/pop_error. */
added by Manu in r6-1748-g5862c189c2c3c2 while fixing PR fortran/66528.
The comment appears to be out of date. I've tested maxerrors.f90 under
valgrind, and it's clean with the patch.
gcc/fortran/ChangeLog:
PR fortran/117442
* error.cc (error_buffer): Convert to a pointer so it can be
heap-allocated.
(gfc_error_now): Update for error_buffer being heap-allocated.
(gfc_clear_error): Likewise.
(gfc_error_flag_test): Likewise.
(gfc_error_check): Likewise.
(gfc_push_error): Likewise.
(gfc_pop_error): Likewise.
(gfc_diagnostics_init): Allocate error_buffer on the heap, rather
than statically.
(gfc_diagnostics_finish): Delete error_buffer.
Signed-off-by: David Malcolm <dmalcolm@redhat.com>
Diffstat (limited to 'gcc/cp')
0 files changed, 0 insertions, 0 deletions