This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [Patch, libfortran] PR 67414 Improve error handling
- From: FX <fxcoudert at gmail dot com>
- To: Janne Blomqvist <blomqvist dot janne at gmail dot com>
- Cc: Fortran List <fortran at gcc dot gnu dot org>, GCC Patches <gcc-patches at gcc dot gnu dot org>
- Date: Tue, 1 Sep 2015 00:04:52 +0200
- Subject: Re: [Patch, libfortran] PR 67414 Improve error handling
- Authentication-results: sourceware.org; auth=none
- References: <CAO9iq9FKnSvGJ36ibh+YFBNvQs=pAqNhdSeSrdE69KViQXU3YA at mail dot gmail dot com>
> the attached patch improves the error handling for backtrace failing,
> by printing the error number or the error string in addition to the
> message. It also fixes a potential null pointer crash in gf_strerror.
>
> Regtested on x86_64-pc-linux-gnu, Ok for trunk?
Mostly OK. I have one question, though: in the specific case from the PR, the error in the backtrace is an OS error (allocating memory), which had set the errno variable. But in other cases, it is (I think) possible that libbacktrace itself fails and call error_callback() without errno being set. In that case, the errno message will be confusing.
So, for that part of the patch, I think it would make more sense to change libbacktrace to give out a reasonable error message (and not âmmapâ). A quick grep through the libbacktrace sources reveal that most calls to error_callback() actually provide insightful error messages. The ones that need to be improved are:
alloc.c: error_callback (data, "malloc", errno);
alloc.c: error_callback (data, "realloc", errno);
alloc.c: error_callback (data, "realloc", errno);
mmap.c: error_callback (data, "mmap", errno);
mmapio.c: error_callback (data, "mmap", errno);
mmapio.c: error_callback (data, "munmap", errno);
posix.c: error_callback (data, "close", errno);
read.c: error_callback (data, "lseek", errno);
read.c: error_callback (data, "read", errno);
FX