Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1639418

Re: [PATCH] perf report: don't crash on invalid maps in `-g srcline` mode

From Paul Clarke <pc@us.ibm.com>
Newsgroups linux.kernel
Subject Re: [PATCH] perf report: don't crash on invalid maps in `-g srcline` mode
Date 2017-05-11 15:20 +0200
Message-ID <tFWaB-6KK-3@gated-at.bofh.it> (permalink)
References <tFkoF-6Y6-17@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


On 05/09/2017 03:50 PM, Milian Wolff wrote:
> diff --git a/tools/perf/util/callchain.c b/tools/perf/util/callchain.c
> index 9ab68682c6d0..295f0846fd84 100644
> --- a/tools/perf/util/callchain.c
> +++ b/tools/perf/util/callchain.c
> @@ -642,13 +642,22 @@ static enum match_result match_chain_strings(const char *left,
>  static enum match_result match_chain_srcline(struct callchain_cursor_node *node,
>  					     struct callchain_list *cnode)
>  {
> -	char *left = get_srcline(cnode->ms.map->dso,
> -				 map__rip_2objdump(cnode->ms.map, cnode->ip),
> -				 cnode->ms.sym, true, false);
> -	char *right = get_srcline(node->map->dso,
> -				  map__rip_2objdump(node->map, node->ip),
> -				  node->sym, true, false);
> -	enum match_result ret = match_chain_strings(left, right);
> +	char *left = NULL;
> +	char *right = NULL;

nit: the above two initializations are unnecessary.

> +	enum match_result ret = MATCH_ERROR;
> +
> +	if (!node->map || !cnode->ms.map)
> +		return ret;
> +
> +	left = get_srcline(cnode->ms.map->dso,
> +			   map__rip_2objdump(cnode->ms.map, cnode->ip),
> +			   cnode->ms.sym, true, false);
> +
> +	right = get_srcline(node->map->dso,
> +			    map__rip_2objdump(node->map, node->ip),
> +			    node->sym, true, false);
> +
> +	ret = match_chain_strings(left, right);
> 
>  	free_srcline(left);
>  	free_srcline(right);

PC

Back to linux.kernel | Previous | NextPrevious in thread | Find similar | Unroll thread


Thread

[PATCH] perf report: don't crash on invalid maps in `-g srcline` mode Milian Wolff <milian.wolff@kdab.com> - 2017-05-09 23:00 +0200
  Re: [PATCH] perf report: don't crash on invalid maps in `-g srcline`  mode Namhyung Kim <namhyung@kernel.org> - 2017-05-10 08:10 +0200
  Re: [PATCH] perf report: don't crash on invalid maps in `-g srcline`  mode Paul Clarke <pc@us.ibm.com> - 2017-05-11 15:20 +0200

csiph-web