Bug 48915 - Incorrect process return code with -fdump-core
Summary: Incorrect process return code with -fdump-core
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: libfortran (show other bugs)
Version: unknown
: P3 minor
Target Milestone: ---
Assignee: Janne Blomqvist
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2011-05-06 11:24 UTC by Janne Blomqvist
Modified: 2011-05-15 10:23 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-06 11:24:58 UTC
Consider the program

program errcode
  stop 10
end program errcode

$ gfortran errcode.f90
$ ./a.out 
STOP 10
$ echo $?
10
$ gfortran -fdump-core errcode.f90 
$ ./a.out 
STOP 10
Quit (core dumped)
$ echo $?
131

Looking at runtime/error.c (sys_exit) the reason is quite obvious; with 

kill(getpid(), SIGQUIT);

the process kills itself (return code is 128 + signal number = 131 in this case) and never gets a chance to execute exit() with the provided exit code!
Comment 1 Janne Blomqvist 2011-05-06 11:31:38 UTC
Assigning to myself, I have some ideas to improve error handling and fix this in the process.
Comment 2 Janne Blomqvist 2011-05-06 11:32:04 UTC
Really assigning this time.
Comment 3 Janne Blomqvist 2011-05-14 08:44:12 UTC
Author: jb
Date: Sat May 14 08:44:09 2011
New Revision: 173750

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=173750
Log:
PR 48915 Abort handling

Modified:
    trunk/gcc/fortran/ChangeLog
    trunk/gcc/fortran/gfortran.h
    trunk/gcc/fortran/gfortran.texi
    trunk/gcc/fortran/intrinsic.texi
    trunk/gcc/fortran/invoke.texi
    trunk/gcc/fortran/lang.opt
    trunk/gcc/fortran/options.c
    trunk/gcc/fortran/trans-decl.c
    trunk/libgfortran/ChangeLog
    trunk/libgfortran/intrinsics/abort.c
    trunk/libgfortran/libgfortran.h
    trunk/libgfortran/runtime/backtrace.c
    trunk/libgfortran/runtime/compile_options.c
    trunk/libgfortran/runtime/environ.c
    trunk/libgfortran/runtime/error.c
    trunk/libgfortran/runtime/stop.c
Comment 4 Janne Blomqvist 2011-05-14 09:05:59 UTC
Fixed, closing.
Comment 5 Janne Blomqvist 2011-05-14 10:20:59 UTC
Author: jb
Date: Sat May 14 10:20:56 2011
New Revision: 173753

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=173753
Log:
PR 48915 Update mixed-language programming documentation

Modified:
    trunk/gcc/fortran/ChangeLog
    trunk/gcc/fortran/gfortran.texi
Comment 6 Janne Blomqvist 2011-05-14 10:24:20 UTC
Author: jb
Date: Sat May 14 10:24:18 2011
New Revision: 173754

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=173754
Log:
PR 48915 Update mixed-language programming documentation

Modified:
    trunk/gcc/fortran/gfortran.texi
Comment 7 Janne Blomqvist 2011-05-15 10:23:56 UTC
Author: jb
Date: Sun May 15 10:23:53 2011
New Revision: 173770

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=173770
Log:
PR 48915 Clarify _gfortran_set_options documentation

Modified:
    trunk/gcc/fortran/ChangeLog
    trunk/gcc/fortran/gfortran.texi