This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [Patch, libfortran] PR 48915 Fix incorrect return code with -fdump-core, error handling changes


Janne Blomqvist wrote: PR libfortran/48915
* lang.opt: Remove -fdump-core.

Shouldn't one set this one to "Ignore" instead of removing it? In particular as in a way the default option is kind of "-fdump-core"?


	* runtime/stop.c (stop_numeric): Call exit().
	(error_stop_string): Call sys_abort().
	(error_stop_numeric): Print backtrace, exit with provided code.

I disagree with the ERROR STOP change. The useful point about backtraces is that one can find out where the program aborted. That's useful when signalling NaN occurs, NULL pointers are dereferenced etc.


However, if either the program prints an error (ERROR STOP) or if the library prints an error where the file/line number is in the error message, it does not make sense to clutter the output by printing a backtrace - especially not if the backtracing is enabled by default.

Thus, I do *not* want to see a backtrace for:
- STOP with non-zero exit code
- ERROR STOP
Both: One can easily grep the source code to find the relevant line. Additionally, those messages usually print the exact problem - thus there is no need to clutter the output.


- Opening an non-existing file
- Out-of-bounds array access
- Deallocating an nonallocated variable
Here, the reason is that the source line is ready printed in the error. For instance:
At line 1 of file test.f90 (unit = 99, file = 'ïR')
Fortran runtime error: File 'nonexist' does not exist


Thus, I think one should to change ERROR STOP back to printing no backtrace - at least not by default.

(I do not really mind backtraces for deallocation or out-of-bounds errors; they occur rare enough and sometimes a backtrace can be useful even if the line number is known.)

Additionally, it is *not* sufficient for ERROR STOP to only modify libgfortran: For -fcoarray=lib, there is also an ERROR STOP version in libgfortran/caf/{single,mpi}.c which should behave analogously - or one changes the code there to call libgfortran's ERROR STOP version from there.

Other than that: Nice clean up. One probably should now also implement backtracing support for Windows, which is not difficult (cf. attachment in the MinGW backtrace PR).

Tobias


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]