[RFC][PATCH] fix gdb segv when objfile can't be opened

Simon Marchi simon.marchi@polymtl.ca
Thu Oct 19 20:10:00 GMT 2017


On 2017-10-19 15:39, Mike Gulick wrote:
> I had trouble figuring out what the 'error' function actually does (I
> couldn't find where it was defined).  When I'm stepping through GDB in
> the debugger, the lines past 'error' never seem to get called.  It's
> like 'error' throws an exception that is caught elsewhere.

Indeed, "error" throws an exception.  You should be able at least to 
step into the error function (although it's not particularly useful nor 
interesting).  It is defined in common/errors.c.

> I was also
> unable to figure out why the error message isn't displayed.  The new
> reproducer shows this issue.  I wasn't sure if setting *size or even
> descriptor->size was the right thing to do, but it seemed reasonable to
> me since the comment in gdb_bfd.h states that this function updates
> *size.  There's currently only one caller for 'gdb_bfd_map_section', so
> I have no problem updating *size there if that is preferred.

Actually it says "If successful, the section data is returned and *SIZE 
is set to the size of the section data;".  And this is what I would 
generally expect from functions.  Unless stated otherwise, the value of 
output parameters should be considered undefined if the function failed. 
  So I would lean towards blaming the caller for not taking enough 
precautions.  It trusts that gdb_bfd_map_section won't fail.

Simon



More information about the Gdb-patches mailing list