public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
From: "Kevin Buettner (Code Review)" <gerrit@gnutoolchain-gerrit.osci.io>
To: gdb-patches@sourceware.org
Cc: Simon Marchi <simon.marchi@polymtl.ca>,
	Luis Machado <luis.machado@linaro.org>
Subject: [review] Avoid infinite recursion in find_pc_sect_line
Date: Wed, 04 Dec 2019 22:04:00 -0000	[thread overview]
Message-ID: <20191204220444.D2E432816F@gnutoolchain-gerrit.osci.io> (raw)
In-Reply-To: <gerrit.1574019611000.I595470be6ab5f61ca7e4e9e70c61a252c0deaeaa@gnutoolchain-gerrit.osci.io>

Kevin Buettner has posted comments on this change.

Change URL: https://gnutoolchain-gerrit.osci.io/r/c/binutils-gdb/+/682
......................................................................


Patch Set 1:

> Patch Set 1:
> 
> I'm not 100% comfortable in merging fixes like this, in an area that's already very tricky, without reproducer.  I'm not strongly opposing either, but just sharing my opinion.
> 
> It just doesn't sound logical.  To reach this "else", we need to:
> 
> 1. lookup a minsym for PC, that minsym is a trampoline.  It means that this trampoline minsym is the closest (smaller or equal) minsym from PC, all minsym types considered.
> 2. lookup a _text_ minsym by name, we find one that is exactly equal to pc
> 
> If that text minsym we have found in #2 is equal to PC, why did we not find it in #1?  The only way I see is for the two minsyms (the trampoline one and the text one) to have the same value.  The lookup function would have returned the trampoline one, because it can only return one symbol, so it has to choose, and the trampoline one happens to come before.  Then, we search specifically text symbols by name, we find the text one.  But that case would already handled with the existing
> 
> 	else if (BMSYMBOL_VALUE_ADDRESS (mfunsym)
> 		 == BMSYMBOL_VALUE_ADDRESS (msymbol))
> 
> So the only explanation I can imagine is that there was another GDB bug, causing it to mess up the minsym creation or lookup.  And either:
> 
> - that bug was fixed, and this fix is no longer needed
> - that bug still isn't fixed, in which case this fix just covers up the problem.
> 
> I think you are already conscious of this, since you added a warning to tell the user that this is not expected.  But if this is a condition we expect to never legitimately happen, I would suggest using an assertion instead:
> 
> 	    gdb_assert (BMSYMBOL_VALUE_ADDRESS (mfunsym) != pc);
> 	    return find_pc_line (BMSYMBOL_VALUE_ADDRESS (mfunsym), 0);
> 
> If this ever happens again in the field, we have more chances to hear about it than if it's a warning that users can easily overlook.

As a GDB user, I'd prefer that GDB do its best to provide a reasonable result. However, as I developer, I too, really want a bug report. I don't have a strong preference either way, so I went (mostly) with your suggestion, but the new patch calls internal_error instead of using an assert. This way, I could include a plea to file a bug report. (Though that may be obvious if you get an assertion failure.)

Anyway, the new patch can be found here:

https://www.sourceware.org/ml/gdb-patches/2019-12/msg00168.html

(I didn't use gerrit to post it.)


-- 
Gerrit-Project: binutils-gdb
Gerrit-Branch: master
Gerrit-Change-Id: I595470be6ab5f61ca7e4e9e70c61a252c0deaeaa
Gerrit-Change-Number: 682
Gerrit-PatchSet: 1
Gerrit-Owner: Kevin Buettner <kevinb@redhat.com>
Gerrit-Reviewer: Kevin Buettner <kevinb@redhat.com>
Gerrit-CC: Luis Machado <luis.machado@linaro.org>
Gerrit-CC: Simon Marchi <simon.marchi@polymtl.ca>
Gerrit-Comment-Date: Wed, 04 Dec 2019 22:04:44 +0000
Gerrit-HasComments: No
Gerrit-Has-Labels: No
Gerrit-MessageType: comment

  parent reply	other threads:[~2019-12-04 22:04 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-11-17 19:40 Kevin Buettner (Code Review)
2019-11-27  2:19 ` Luis Machado (Code Review)
2019-11-27 20:13 ` Kevin Buettner (Code Review)
2019-11-27 23:00 ` Simon Marchi (Code Review)
2019-12-04 22:04 ` Kevin Buettner (Code Review) [this message]
2020-03-12  5:59 ` [pushed] " Sourceware to Gerrit sync (Code Review)
2020-03-12  5:59 ` Sourceware to Gerrit sync (Code Review)

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=20191204220444.D2E432816F@gnutoolchain-gerrit.osci.io \
    --to=gerrit@gnutoolchain-gerrit.osci.io \
    --cc=gdb-patches@sourceware.org \
    --cc=gnutoolchain-gerrit@osci.io \
    --cc=luis.machado@linaro.org \
    --cc=simon.marchi@polymtl.ca \
    /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).