public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Gleb Natapov <gleb@redhat.com>
To: Arnaldo Carvalho de Melo <acme@infradead.org>
Cc: linux-kernel@vger.kernel.org, mingo@elte.hu,
	peterz@infradead.org, paulus@samba.org
Subject: Re: [PATCH v2] Re: perf annotate segfaults when source code has goto label that looks like hex number
Date: Thu, 22 Jul 2010 21:05:38 +0300	[thread overview]
Message-ID: <20100722180538.GB10307@redhat.com> (raw)
In-Reply-To: <20100722170541.GF17631@ghostprotocols.net>

On Thu, Jul 22, 2010 at 02:05:42PM -0300, Arnaldo Carvalho de Melo wrote:
> Em Thu, Jul 22, 2010 at 01:52:22PM -0300, Arnaldo Carvalho de Melo escreveu:
> > Em Thu, Jul 22, 2010 at 01:47:11PM -0300, Arnaldo Carvalho de Melo escreveu:
> > > Em Thu, Jul 22, 2010 at 07:38:51PM +0300, Gleb Natapov escreveu:
> > > > On Thu, Jul 22, 2010 at 11:33:45AM -0300, Arnaldo Carvalho de Melo wrote:
> > > > > Can you try the attached patch?
> > > > > 
> > > > I can, only later. But if I underhand your patch correctly perf will
> > > > still crash if there is a comment after the label on the same line.
> > > 
> > > Possibly, will try that now.
> > 
> > It could be a comment of play code, like:
> > 
> > [root@emilia ~]# cat test.c 
> > int main(int argc, char **argv)
> > {
> >       int i;
> > 
> >       while(1) {
> >               i++;
> >               if (i == 10000000)
> >                       goto add;
> >       }
> > add:	return 0;
> > }
> > [root@emilia ~]#
> > 
> > back to the drawing board :-\
> 
> What about this one?
> 
> diff --git a/tools/perf/util/hist.c b/tools/perf/util/hist.c
> index 699cf81..96e9044 100644
> --- a/tools/perf/util/hist.c
> +++ b/tools/perf/util/hist.c
> @@ -976,13 +976,15 @@ static int hist_entry__parse_objdump_line(struct hist_entry *self, FILE *file,
>  		 * Parse hexa addresses followed by ':'
>  		 */
>  		line_ip = strtoull(tmp, &tmp2, 16);
> -		if (*tmp2 != ':' || tmp == tmp2)
> +		if (*tmp2 != ':' || tmp == tmp2 || tmp2[1] == '\0')
>  			line_ip = -1;
>  	}
>  
>  	if (line_ip != -1) {
>  		u64 start = map__rip_2objdump(self->ms.map, sym->start);
>  		offset = line_ip - start;
> +		if (offset < 0 || (u64)line_ip > sym->end)
> +			offset = -1;
>  	}
>  
This part is good idea anyway. Even if label will be interpreted as ip
perf at least will not crash. It may miss-report something if check will
accidentally succeed though.

>  	objdump_line = objdump_line__new(offset, line);

--
			Gleb.

  reply	other threads:[~2010-07-22 18:06 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-07-22  7:20 perf annotate segfaults when source code has goto label that looks like hex number Gleb Natapov
2010-07-22 14:33 ` [PATCH] " Arnaldo Carvalho de Melo
2010-07-22 16:38   ` Gleb Natapov
2010-07-22 16:47     ` Arnaldo Carvalho de Melo
2010-07-22 16:52       ` Arnaldo Carvalho de Melo
2010-07-22 17:05         ` [PATCH v2] " Arnaldo Carvalho de Melo
2010-07-22 18:05           ` Gleb Natapov [this message]
2010-07-22 19:11             ` Arnaldo Carvalho de Melo
2010-07-22 19:16               ` Gleb Natapov
2010-08-02  9:02               ` Peter Zijlstra
2010-08-02 14:52                 ` Arnaldo Carvalho de Melo
2010-07-23 12:11           ` [tip:perf/urgent] perf annotate: Fix handling of goto labels that are valid hex numbers tip-bot for Arnaldo Carvalho de Melo

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=20100722180538.GB10307@redhat.com \
    --to=gleb@redhat.com \
    --cc=acme@infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@elte.hu \
    --cc=paulus@samba.org \
    --cc=peterz@infradead.org \
    /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