From: Pedro Alves <palves@redhat.com>
To: Markus Metzger <markus.t.metzger@intel.com>
Cc: gdb-patches@sourceware.org
Subject: Re: [PATCH] btrace, frame: fix crash in get_frame_type
Date: Thu, 04 Feb 2016 16:01:00 -0000 [thread overview]
Message-ID: <56B375EE.7020407@redhat.com> (raw)
In-Reply-To: <1453828132-2319-1-git-send-email-markus.t.metzger@intel.com>
On 01/26/2016 05:08 PM, Markus Metzger wrote:
> In skip_artificial_frames we repeatedly call get_prev_frame_always until we get
> a non-inline and non-tailcall frame assuming that there must be such a frame
> eventually.
>
> For record targets, however, we may have a frame chain that consists only of
> inline or tailcall frames.
>
> This leads to a crash in get_frame_type when we dereference a NULL frame
> pointer.
>
> The comment on skip_artificial_frames says
>
> /* Given FRAME, return the enclosing frame as found in real frames read-in from
> inferior memory. Skip any previous frames which were made up by GDB.
> Return the original frame if no immediate previous frames exist. */
>
> That last part, "return the original frame if no immediate previous frames
> exist", is missing. I added that.
Not sure about this. Why does it make sense to return the original frame?
It sounds arbitrary -- could just as well be the outermost? What does the
caller in question do with it, and why is it correct?
> I found two other places where get_frame_type is called in a similar setup to
> skip tailcall frames:
>
> - in infcmd.c to implement the "finish" command
> - in frame.c's pop_frame which is used by the "return" command
>
> In both cases I added a NULL pointer check for the frame and throw an error in
> case we don't find a non-tailcall frame.
> /* Ignore TAILCALL_FRAME type frames, they were executed already before
> entering THISFRAME. */
> - while (get_frame_type (prev_frame) == TAILCALL_FRAME)
> + while (prev_frame != NULL && get_frame_type (prev_frame) == TAILCALL_FRAME)
> prev_frame = get_prev_frame (prev_frame);
>
> + /* We cannot pop tailcall frames. */
> + if (prev_frame == NULL)
> + error (_("Cannot pop tailcall frame(s)."));
> +
How about factoring that out to a skip_tailcall_frames
function, similar to skip_artificial_frames, and then do:
prev_frame = skip_tailcall_frames (prev_frame);
if (prev_frame == NULL)
error (_("Cannot pop tailcall frame(s)."));
here and similarly in the other case.
And I wonder whether we should be using get_prev_frame_always
for this too, like skip_artificial_frames uses.
>
> In infcmd I further moved the tailcall-frame-chasing loop to the
> forward-stepping case since we don't need a frame for reverse execution and we
> don't want to fail because of that. Reverse-finish does make sense for a
> tailcall frame.
Thanks,
Pedro Alves
next prev parent reply other threads:[~2016-02-04 16:01 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-01-26 17:09 Markus Metzger
2016-02-04 16:01 ` Pedro Alves [this message]
2016-02-05 8:23 ` Metzger, Markus T
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=56B375EE.7020407@redhat.com \
--to=palves@redhat.com \
--cc=gdb-patches@sourceware.org \
--cc=markus.t.metzger@intel.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