This is the mail archive of the gdb-patches@sourceware.org mailing list for the GDB 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] Catch exception on solib_svr4_r_ldsomap


On 03/27/2015 10:34 PM, Sergio Durigan Junior wrote:
> On Friday, March 27 2015, Pedro Alves wrote:
> 
>> On 03/25/2015 12:06 AM, Sergio Durigan Junior wrote:> Hi,
>>>
>>> While hacking the coredump_filter patch, I noticed that, when you load a
>>> corefile on GDB and receive a "Cannot access memory at address..."
>>> message, gdb_core_cmd will fail and return -1, which means that some
>>> fatal error happened.
>>>
>>> Unfortunately, this kind of message does not mean that the user cannot
>>> continue debugging with the corefile; it meant that some memory region
>>> (sometimes not important) was inaccessible.  Given that
>>> gcore_create_callback, nowadays, will dump memory regions if they don't
>>> have the 'read' permission set (but have any other permission set), this
>>> kind of error can be expected sometimes.
>>
>> So, gdb itself errors and stops processing the core?
> 
> No, GDB does not "error and stop", but some testcases do that.  

Well, it clearly does do that.   Hence your new patch.  :-)

>> I think I don't understand.  :-)  Can you please show an
>> example session?  Did GDB continue processing the core when
>> it printed that error, or was it just a warning and it continued?
> 

I meant "Did GDB stop processing the core", of course.

> Sure, sorry for not sending the example session before!  Here is the
> pertinent part:
> 
>   (gdb) core /home/sergio/work/src/git/binutils-gdb/rhbz1085906-coredump-filter/build-64-3/gdb/testsuite/gdb.base/non-private-anon.gcore
>   [New LWP 28468]
>   Cannot access memory at address 0x355fc21148
>   Cannot access memory at address 0x355fc21140
>   (gdb) FAIL: gdb.base/coredump-filter.exp: loading and testing corefile for non-Private-Anonymous: load core
>   FAIL: gdb.base/coredump-filter.exp: loading and testing corefile for non-Private-Anonymous: loading /home/sergio/work/src/git/binutils-gdb/rhbz1085906-coredump-filter/build-64-3/gdb/testsuite/gdb.base/non-private-anon.gcore
>   spawn /home/sergio/work/src/git/binutils-gdb/rhbz1085906-coredump-filter/build-64-3/gdb/testsuite/../../gdb/gdb -nw -nx -data-directory /home/sergio/work/src/git/binutils-gdb/rhbz1085906-coredump-filter/build-64-3/gdb/testsuite/../data-directory
>   ...
> 
> GDB correctly loaded the corefile (despite the warnings), and the

The error made the rest of core_open be skipped: if the core is still
loaded, gdb is potentially in an inconsistent state at this point.
I'd think we should completely discard the core/target if something
errors out.  And then if we can be tolerant to specific parts of
loading a core failing, we should handle those before the error escapes
out of core_open.  We do something like that
already (note core_close_cleanup and the TRY/CATCH'S), but it's clearly
not complete.  After:

  push_target (&core_ops);
  discard_cleanups (old_chain);

... several things can throw and let an exception escape.

> Right, so I took some time and found the right fix, I think.  As we
> agreed above, the fact that GDB is not printing the "Core was generated
> by..." message is really strange, so I decided to investigate why it is
> doing that.
> 
> The answer is that we are forgetting to check for an exception on
> solib_svr4_r_ldsomap.  When loading the corefile, GDB calls this
> function, which then calls read_memory_unsigned_integer, which throws an
> error.  This error is not being caught by the function, so it propagates
> until the main loop catches it.  The fix is obvious: we should catch
> this regression and continue in the function.  With it, GDB now
> correctly prints the "Core was generated by..." message, and the patch
> to adjust gdb_core_cmd is no longer needed.
> 
> Regression-tested on Fedora 20 for x86_64, i686 and native-gdbserver.
> 
> Does that make more sense now?
> 

Yes, this is OK.

Thanks,
Pedro Alves


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