public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
From: Andrew Burgess <aburgess@redhat.com>
To: Bruno Larsen <blarsen@redhat.com>
Cc: Tom Tromey <tom@tromey.com>,
	Bruno Larsen via Gdb-patches <gdb-patches@sourceware.org>
Subject: Re: [PATCH] gdb/stack.c: avoid stale pointers when printing frame arguments
Date: Tue, 5 Apr 2022 17:39:55 +0100	[thread overview]
Message-ID: <20220405163955.GX1212730@redhat.com> (raw)
In-Reply-To: <d5eb6036-b1c7-7266-9feb-e27fae624895@redhat.com>

* Bruno Larsen via Gdb-patches <gdb-patches@sourceware.org> [2022-04-05 11:47:20 -0300]:

> On 4/5/22 10:58, Tom Tromey wrote:
> > > > > > > "Bruno" == Bruno Larsen <blarsen@redhat.com> writes:
> > 
> > Bruno> This sounds like a good idea. I am just not sure if you are
> > Bruno> suggesting it as a fix instead of what I proposed, or to
> > Bruno> implement later, can you clarify it please?
> > 
> > You don't have to do it.
> > 
> > Bruno> +  if (frame_cache_count < get_frame_cache_generation ())
> > Bruno> +    reinit_frame_cache ();
> > 
> > > > I don't think I understand this bit.  If the generation changes,
> > > > hasn't
> > > > the cache already been cleared?
> > 
> > Bruno> If the cache has been cleared by printing a frame, it was done because
> > Bruno> a function was called manually (probably). If it did happen, the cache
> > Bruno> may have been invalidated and it is safer to rebuild
> > Bruno> everything. print_frame_cache by itself doesn't reinitialize the frame
> > Bruno> cache.
> > 
> > My understanding is that the generation only changes when
> > reinit_frame_cache is called.  So if that's the case, why does it need
> > to be reinitalized a second time?  That's the part I don't understand.
> 
> It has been reinitialized to call the function by hand (if you set
> debug frame 1 and call something by hand, you'll see a few
> refreshes), but it is not been refreshed after finishing the
> handmade call. We might still have dummy frames or incorrect
> information leftover from the function call.

If the handmade (inferior) call can leave invalid frames in the frame
cache, then the correct thing (I would think) is to flush the frame
cache after making the inferior call.

Thanks,
Andrew


  reply	other threads:[~2022-04-05 16:40 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-03-28 17:57 Bruno Larsen
2022-04-04 19:06 ` Tom Tromey
2022-04-04 21:42   ` Bruno Larsen
2022-04-05 13:58     ` Tom Tromey
2022-04-05 14:47       ` Bruno Larsen
2022-04-05 16:39         ` Andrew Burgess [this message]
2022-04-05 16:54 ` Andrew Burgess

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=20220405163955.GX1212730@redhat.com \
    --to=aburgess@redhat.com \
    --cc=blarsen@redhat.com \
    --cc=gdb-patches@sourceware.org \
    --cc=tom@tromey.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).