> 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

Reply via email to