public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug fortran/67414] New: [5 Regression] Error message on failed allocate
@ 2015-08-31 16:32 Joost.VandeVondele at mat dot ethz.ch
  2015-08-31 21:03 ` [Bug fortran/67414] " jb at gcc dot gnu.org
                   ` (3 more replies)
  0 siblings, 4 replies; 5+ messages in thread
From: Joost.VandeVondele at mat dot ethz.ch @ 2015-08-31 16:32 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=67414

            Bug ID: 67414
           Summary: [5 Regression] Error message on failed allocate
           Product: gcc
           Version: 6.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: fortran
          Assignee: unassigned at gcc dot gnu.org
          Reporter: Joost.VandeVondele at mat dot ethz.ch
  Target Milestone: ---

For 4.9 and earlier a gfortran compiled binary would print a clear error
message if an allocate would fail like in:

> cat test.f90 
INTEGER, POINTER, DIMENSION(:) :: leak
DO
  ALLOCATE(leak(1000))
  leak=0
ENDDO
END
> gfortran -g test.f90
> ulimit -v 1000000
> ./a.out
Operating system error: Cannot allocate memory
Allocation would exceed memory limit

With gcc 5 I get only part of the error, but also a backtrace (which is nice) :

> ./a.out
Operating system error: 
Program received signal SIGSEGV: Segmentation fault - invalid memory reference.

Backtrace for this error:
#0  0x7F610BCC0B87
#1  0x7F610BCBFD80
#2  0x3BA4A3269F
#3  0x3BA4A2B38F
#4  0x7F610BCC1A92
#5  0x7F610BCC1B80
#6  0x400786 in MAIN__ at test.f90:3 (discriminator 3)
Segmentation fault

With gcc 6, unfortunately, the backtrace is replace with an error message:
> ./a.out
Operating system error: 
Program received signal SIGSEGV: Segmentation fault - invalid memory reference.

Backtrace for this error:

Something went wrong while printing the backtrace: mmap

Something went wrong while printing the backtrace: mmap

Something went wrong while printing the backtrace: mmap
Segmentation fault

Ideally, we get both the clear error message and a backtrace.


^ permalink raw reply	[flat|nested] 5+ messages in thread

* [Bug fortran/67414] [5 Regression] Error message on failed allocate
  2015-08-31 16:32 [Bug fortran/67414] New: [5 Regression] Error message on failed allocate Joost.VandeVondele at mat dot ethz.ch
@ 2015-08-31 21:03 ` jb at gcc dot gnu.org
  2015-09-01  8:34 ` [Bug fortran/67414] [5/6 " rguenth at gcc dot gnu.org
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 5+ messages in thread
From: jb at gcc dot gnu.org @ 2015-08-31 21:03 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=67414

Janne Blomqvist <jb at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |NEW
   Last reconfirmed|                            |2015-08-31
                 CC|                            |fxcoudert at gcc dot gnu.org,
                   |                            |jb at gcc dot gnu.org
     Ever confirmed|0                           |1

--- Comment #1 from Janne Blomqvist <jb at gcc dot gnu.org> ---
Confirmed.

I'd say this is a WONTFIX. The reason is that with the new libbacktrace-based
backtrace code the backtrace is generated in the same process, whereas the old
implementation forked a copy of addr2line which did the symbol lookup. So when
the code fails due to bumping into the memory limit, generating the backtrace
fails. However, as there are several benefits of the new libbacktrace way, I
don't think we want to go back to the old addr2line way.

That being said, I have a patch which 1) Improves the error message for
backtracing failing 2) Fixes the root case for the segfault here. Fixing issue
2) actually makes the backtrace go away, so uh.. Well, that's more an issue for
PR 53379 anyway.


^ permalink raw reply	[flat|nested] 5+ messages in thread

* [Bug fortran/67414] [5/6 Regression] Error message on failed allocate
  2015-08-31 16:32 [Bug fortran/67414] New: [5 Regression] Error message on failed allocate Joost.VandeVondele at mat dot ethz.ch
  2015-08-31 21:03 ` [Bug fortran/67414] " jb at gcc dot gnu.org
@ 2015-09-01  8:34 ` rguenth at gcc dot gnu.org
  2015-09-02 14:52 ` jb at gcc dot gnu.org
  2015-09-02 15:16 ` jb at gcc dot gnu.org
  3 siblings, 0 replies; 5+ messages in thread
From: rguenth at gcc dot gnu.org @ 2015-09-01  8:34 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=67414

Richard Biener <rguenth at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
   Target Milestone|---                         |5.3
            Summary|[5 Regression] Error        |[5/6 Regression] Error
                   |message on failed allocate  |message on failed allocate


^ permalink raw reply	[flat|nested] 5+ messages in thread

* [Bug fortran/67414] [5/6 Regression] Error message on failed allocate
  2015-08-31 16:32 [Bug fortran/67414] New: [5 Regression] Error message on failed allocate Joost.VandeVondele at mat dot ethz.ch
  2015-08-31 21:03 ` [Bug fortran/67414] " jb at gcc dot gnu.org
  2015-09-01  8:34 ` [Bug fortran/67414] [5/6 " rguenth at gcc dot gnu.org
@ 2015-09-02 14:52 ` jb at gcc dot gnu.org
  2015-09-02 15:16 ` jb at gcc dot gnu.org
  3 siblings, 0 replies; 5+ messages in thread
From: jb at gcc dot gnu.org @ 2015-09-02 14:52 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=67414

--- Comment #3 from Janne Blomqvist <jb at gcc dot gnu.org> ---
Author: jb
Date: Wed Sep  2 14:51:40 2015
New Revision: 227404

URL: https://gcc.gnu.org/viewcvs?rev=227404&root=gcc&view=rev
Log:
PR 67414 Better diagnostics on backtrace failure, gf_strerror bugfix

2015-09-02  Janne Blomqvist  <jb@gcc.gnu.org>

        PR libfortran/67414
        * io/write.c (gfc_itoa): Move to runtime/string.c.
        * libgfortran.h (show_backtrace): Make arg bool.
        (gfc_itoa): New prototype.
        * runtime/backtrace.c (struct mystate): Change type of try_simple
        field, add in_signal_handler field.
        (error_callback): Print out error number, or if not in a signal
        handler, the error message.
        (show_backtrace): Change type of arg, change initialization of
        struct mystate.
        (backtrace): Call show_backtrace with correct arg type.
        * runtime/compile_options.c (backtrace_handler): Call with correct
        arg type.
        * runtime/error.c (sys_abort): Likewise.
        (gf_strerror): Handle newlocale() failure.
        * runtime/string.c (gfc_itoa): Function moved here from
        io/write.c.

Modified:
    trunk/libgfortran/ChangeLog
    trunk/libgfortran/io/write.c
    trunk/libgfortran/libgfortran.h
    trunk/libgfortran/runtime/backtrace.c
    trunk/libgfortran/runtime/compile_options.c
    trunk/libgfortran/runtime/error.c
    trunk/libgfortran/runtime/string.c


^ permalink raw reply	[flat|nested] 5+ messages in thread

* [Bug fortran/67414] [5/6 Regression] Error message on failed allocate
  2015-08-31 16:32 [Bug fortran/67414] New: [5 Regression] Error message on failed allocate Joost.VandeVondele at mat dot ethz.ch
                   ` (2 preceding siblings ...)
  2015-09-02 14:52 ` jb at gcc dot gnu.org
@ 2015-09-02 15:16 ` jb at gcc dot gnu.org
  3 siblings, 0 replies; 5+ messages in thread
From: jb at gcc dot gnu.org @ 2015-09-02 15:16 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=67414

Janne Blomqvist <jb at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
         Resolution|---                         |FIXED

--- Comment #5 from Janne Blomqvist <jb at gcc dot gnu.org> ---
Fixed, closing. The remaining question of when a backtrace is appropriate and
when it isn't is a topic for PR 53379.

I backported the gf_strerror fix to the gcc-5 branch as well.


^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2015-09-02 15:16 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-08-31 16:32 [Bug fortran/67414] New: [5 Regression] Error message on failed allocate Joost.VandeVondele at mat dot ethz.ch
2015-08-31 21:03 ` [Bug fortran/67414] " jb at gcc dot gnu.org
2015-09-01  8:34 ` [Bug fortran/67414] [5/6 " rguenth at gcc dot gnu.org
2015-09-02 14:52 ` jb at gcc dot gnu.org
2015-09-02 15:16 ` jb at gcc dot gnu.org

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).