lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20191017192832.GB3600@kernel.org>
Date:   Thu, 17 Oct 2019 16:28:32 -0300
From:   Arnaldo Carvalho de Melo <arnaldo.melo@...il.com>
To:     Steven Rostedt <rostedt@...dmis.org>
Cc:     Arnaldo Carvalho de Melo <arnaldo.melo@...il.com>,
        Tzvetomir Stoyanov <tstoyanov@...are.com>,
        Jiri Olsa <jolsa@...nel.org>,
        Namhyung Kim <namhyung@...nel.org>,
        Linux Kernel Mailing List <linux-kernel@...r.kernel.org>
Subject: Re: [BUG] libtraceevent: perf script -g python segfaults

Em Thu, Oct 17, 2019 at 02:41:14PM -0400, Steven Rostedt escreveu:
> On Thu, 17 Oct 2019 14:38:41 -0400
> Steven Rostedt <rostedt@...dmis.org> wrote:
> 
> >  struct tep_event *trace_find_next_event(struct tep_handle *pevent,
> >  					struct tep_event *event)
> >  {
> > +	static struct tep_event **all_events;
> >  	static int idx;
> >  	int events_count;
> > -	struct tep_event *all_events;
> 
> If we are going to use static variables, let's make them all static and
> optimize it a little more...

I'll test it, but can't you have this somewhere else, i.e. at
tep_handle perhaps?

- Arnaldo
 
> -- Steve
> 
> diff --git a/tools/perf/util/trace-event-parse.c b/tools/perf/util/trace-event-parse.c
> index ad74be1f0e42..3f23462517a3 100644
> --- a/tools/perf/util/trace-event-parse.c
> +++ b/tools/perf/util/trace-event-parse.c
> @@ -193,30 +193,35 @@ int parse_event_file(struct tep_handle *pevent,
>  struct tep_event *trace_find_next_event(struct tep_handle *pevent,
>  					struct tep_event *event)
>  {
> +	static struct tep_event **all_events;
> +	static int events_count;
>  	static int idx;
> -	int events_count;
> -	struct tep_event *all_events;
>  
> -	all_events = tep_get_first_event(pevent);
> -	events_count = tep_get_events_count(pevent);
> -	if (!pevent || !all_events || events_count < 1)
> +	if (!pevent || !all_events)
>  		return NULL;
>  
>  	if (!event) {
>  		idx = 0;
> -		return all_events;
> +		events_count = tep_get_events_count(pevent);
> +		if (events_count < 1)
> +			return NULL;
> +
> +		all_events = tep_list_events(pevent, TEP_EVENT_SORT_ID);
> +		if (all_events)
> +			return all_events[0];
> +		return NULL;
>  	}
>  
> -	if (idx < events_count && event == (all_events + idx)) {
> +	if (idx < events_count && event == all_events[idx]) {
>  		idx++;
>  		if (idx == events_count)
>  			return NULL;
> -		return (all_events + idx);
> +		return all_events[idx];
>  	}
>  
>  	for (idx = 1; idx < events_count; idx++) {
> -		if (event == (all_events + (idx - 1)))
> -			return (all_events + idx);
> +		if (event == all_events[idx - 1])
> +			return all_events[idx];
>  	}
>  	return NULL;
>  }

-- 

- Arnaldo

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ