Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: "Metzger, Markus T" <markus.t.metzger@intel.com>
To: Pedro Alves <palves@redhat.com>
Cc: "gdb-patches@sourceware.org" <gdb-patches@sourceware.org>
Subject: RE: [PATCH v2 3/3] btrace, frame: fix crash in get_frame_type
Date: Tue, 09 Feb 2016 14:43:00 -0000	[thread overview]
Message-ID: <A78C989F6D9628469189715575E55B233325FC44@IRSMSX104.ger.corp.intel.com> (raw)
In-Reply-To: <56B9D620.2020104@redhat.com>

> -----Original Message-----
> From: Pedro Alves [mailto:palves@redhat.com]
> Sent: Tuesday, February 9, 2016 1:06 PM
> To: Metzger, Markus T <markus.t.metzger@intel.com>
> Cc: gdb-patches@sourceware.org
> Subject: Re: [PATCH v2 3/3] btrace, frame: fix crash in get_frame_type
> 
> On 02/05/2016 02:18 PM, Markus Metzger wrote:
> 
> > diff --git a/gdb/frame.c b/gdb/frame.c index 6ab8834..cea7003 100644
> > --- a/gdb/frame.c
> > +++ b/gdb/frame.c
> > @@ -420,7 +420,8 @@ fprint_frame (struct ui_file *file, struct
> > frame_info *fi)
> >
> >  /* 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.  */
> > +   Return FRAME if FRAME is a non-artificial frame.
> > +   Return NULL if FRAME is NULL or the start of an artificial-only
> > + chain. */
> 
> Missing double-space after period.  But, most importantly, I'm not sure I like
> that this accepts a NULL frame.

Fine with me.


> > @@ -511,11 +517,12 @@ frame_unwind_caller_id (struct frame_info
> *next_frame)
> >       requests the frame ID of "main()"s caller.  */
> >
> >    next_frame = skip_artificial_frames (next_frame);
> > -  this_frame = get_prev_frame_always (next_frame);
> > -  if (this_frame)
> > -    return get_frame_id (skip_artificial_frames (this_frame));
> > -  else
> > +  if (next_frame == NULL)
> >      return null_frame_id;
> > +
> > +  this_frame = get_prev_frame_always (next_frame);  this_frame =
> > + skip_artificial_frames (this_frame);  return get_frame_id
> > + (this_frame);
> >  }
> >
> >  const struct frame_id null_frame_id = { 0 }; /* All zeros.  */ @@
> > -795,6 +802,9 @@ frame_find_by_id (struct frame_id id)  static
> > CORE_ADDR  frame_unwind_pc (struct frame_info *this_frame)  {
> > +  if (this_frame == NULL)
> > +    throw_error (NOT_AVAILABLE_ERROR, _("PC not available"));
> 
> How can this happen?

One of its callers, frame_unwind_caller_pc, calls it with the result of
skip_artificial_frames like this:

CORE_ADDR
frame_unwind_caller_pc (struct frame_info *this_frame)
{
  return frame_unwind_pc (skip_artificial_frames (this_frame));
}

Rather than handling the skip_artificial_frames() NULL return here,
I made frame_unwind_pc handle a NULL frame argument.

I can move the check into frame_unwind_caller_pc if you prefer.


> > +  /* If the frame chain consists only of artificial frames, use
> NEXT_FRAME's.
> > +
> > +     For tailcall frames, we (i.e. the DWARF frame unwinder) assume that
> they
> > +     have the gdbarch of the bottom (callee) frame.  If NEXT_FRAME is an
> > +     artificial frame, as well, we should drill down to the bottom in
> > +     frame_unwind_arch either directly via the tailcall unwinder or via a
> chain
> > +     of get_frame_arch calls.  */
> > +  caller = skip_artificial_frames (next_frame);  if (caller == NULL)
> > +    get_frame_arch (next_frame);
> > +
> > +  return frame_unwind_arch (next_frame);
> 
> Hmm, this looks odd.  Is the get_frame_arch call there for side effects, or did
> you mean to make that "return get_frame_arch" ?

Ouch.  Yes, I meant to return that frame.


Regards,
Markus.

Intel Deutschland GmbH
Registered Address: Am Campeon 10-12, 85579 Neubiberg, Germany
Tel: +49 89 99 8853-0, www.intel.de
Managing Directors: Christin Eisenschmid, Christian Lamprechter
Chairperson of the Supervisory Board: Nicole Lau
Registered Office: Munich
Commercial Register: Amtsgericht Muenchen HRB 186928


  reply	other threads:[~2016-02-09 14:43 UTC|newest]

Thread overview: 27+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-02-05 14:18 [PATCH v2 1/3] frame: add skip_tailcall_frames Markus Metzger
2016-02-05 14:18 ` [PATCH v2 2/3] frame: use get_prev_frame_always in skip_tailcall_frames Markus Metzger
2016-02-07 13:01   ` Joel Brobecker
2016-02-08  8:14     ` Metzger, Markus T
2016-02-09 11:42       ` Pedro Alves
2016-02-09 11:58         ` Joel Brobecker
2016-02-09 14:25           ` Metzger, Markus T
2016-02-09 14:41             ` Pedro Alves
     [not found]               ` <A78C989F6D9628469189715575E55B233325FCA0@IRSMSX104.ger.corp.intel.com>
2016-02-15  9:51                 ` Metzger, Markus T
2016-02-17 15:32                   ` Pedro Alves
2016-02-19 11:36                     ` Metzger, Markus T
2016-02-09 14:44             ` Joel Brobecker
2016-02-05 14:19 ` [PATCH v2 3/3] btrace, frame: fix crash in get_frame_type Markus Metzger
2016-02-09 12:05   ` Pedro Alves
2016-02-09 14:43     ` Metzger, Markus T [this message]
2016-02-09 22:01       ` Pedro Alves
2016-02-10  7:40         ` Metzger, Markus T
2016-02-10  9:59           ` Pedro Alves
2016-02-10 10:29             ` Metzger, Markus T
2016-02-10 15:02               ` Metzger, Markus T
2016-02-10 15:34                 ` Pedro Alves
2016-02-11  9:51                   ` Metzger, Markus T
2016-02-11 13:39                     ` Pedro Alves
2016-02-11 15:42                       ` Metzger, Markus T
2016-02-11 15:58                         ` Pedro Alves
2016-02-11 16:07                           ` Metzger, Markus T
2016-02-07 13:00 ` [PATCH v2 1/3] frame: add skip_tailcall_frames Joel Brobecker

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=A78C989F6D9628469189715575E55B233325FC44@IRSMSX104.ger.corp.intel.com \
    --to=markus.t.metzger@intel.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