public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
From: Sergio Durigan Junior <sergiodj@redhat.com>
To: Pedro Alves <palves@redhat.com>
Cc: GDB Patches <gdb-patches@sourceware.org>
Subject: Re: [PATCH] Catch exception on solib_svr4_r_ldsomap
Date: Tue, 31 Mar 2015 23:39:00 -0000	[thread overview]
Message-ID: <878uecvirs.fsf@redhat.com> (raw)
In-Reply-To: <551A8546.4000208@redhat.com> (Pedro Alves's message of "Tue, 31	Mar 2015 12:30:14 +0100")

On Tuesday, March 31 2015, Pedro Alves wrote:

>>> 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.

Sorry I misunderstood your question.

>> 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.

Yeah, certainly we should be catching those before they escape.  I will
see if I can take a look at more places to improve/fix later.

>> 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, pushed:

  <https://sourceware.org/ml/gdb-cvs/2015-03/msg00274.html>
  416f679e68468ea6dd7384213994ce74201f82e7

-- 
Sergio
GPG key ID: 0x65FC5E36
Please send encrypted e-mail if possible
http://sergiodj.net/

      reply	other threads:[~2015-03-31 23:39 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-03-25  0:06 [RFC/PATCH] Extend gdb_core_cmd to allow "Cannot access memory..." messages Sergio Durigan Junior
2015-03-27 10:06 ` Pedro Alves
2015-03-27 22:34   ` [PATCH] Catch exception on solib_svr4_r_ldsomap (was: Re: [RFC/PATCH] Extend gdb_core_cmd to allow "Cannot access memory..." messages) Sergio Durigan Junior
2015-03-31 11:30     ` [PATCH] Catch exception on solib_svr4_r_ldsomap Pedro Alves
2015-03-31 23:39       ` Sergio Durigan Junior [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=878uecvirs.fsf@redhat.com \
    --to=sergiodj@redhat.com \
    --cc=gdb-patches@sourceware.org \
    --cc=palves@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).