From: Arnaldo Carvalho de Melo <acme@kernel.org>
To: Andi Kleen <ak@linux.intel.com>
Cc: Andi Kleen <andi@firstfloor.org>,
jolsa@kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH 2/2] perf, tools: Avoid segfault on alias parse error
Date: Thu, 17 Aug 2017 14:22:32 -0300 [thread overview]
Message-ID: <20170817172232.GF10891@kernel.org> (raw)
In-Reply-To: <20170817170453.GL28715@tassilo.jf.intel.com>
Em Thu, Aug 17, 2017 at 10:04:53AM -0700, Andi Kleen escreveu:
> > So it will _not_ set to null a member that it doesn't have, i.e. the
> > minimal fix is to just have the hunks below, making sure that the error
> > field is present in both structs. No need to set
> > parse_event_terms->error to anything, it will be set to null since other
> > fields are set to something.
>
> Right but I want to see the error too. That is why I added a real
> error handler.
Ok, but I was first trying to figure out the fix for that separate
problem (the void pointer being dereferenced to two different types in
the same function, yyparse, aka parse_events_parse), then we can go to
the 'too' part :-)
I'm adding the patch below, that should fix things by using just one
state struct for parsing.
This is done on top of another that renames 'struct parse_events_evlist'
to a more clearer 'struct parse_events_state'.
I'll then add what is left of your patch, run tests and we go from
there, holler if I'm now missing something.
- Arnaldo
diff --git a/tools/perf/util/parse-events.c b/tools/perf/util/parse-events.c
index 272eab7f5ac8..d4fcf048aa9e 100644
--- a/tools/perf/util/parse-events.c
+++ b/tools/perf/util/parse-events.c
@@ -1656,7 +1656,7 @@ static int parse_events__scanner(const char *str, void *data, int start_token)
*/
int parse_events_terms(struct list_head *terms, const char *str)
{
- struct parse_events_terms data = {
+ struct parse_events_state data = {
.terms = NULL,
};
int ret;
diff --git a/tools/perf/util/parse-events.h b/tools/perf/util/parse-events.h
index 8fff8423469b..2a3617937894 100644
--- a/tools/perf/util/parse-events.h
+++ b/tools/perf/util/parse-events.h
@@ -114,10 +114,7 @@ struct parse_events_state {
int nr_groups;
struct parse_events_error *error;
struct perf_evlist *evlist;
-};
-
-struct parse_events_terms {
- struct list_head *terms;
+ struct list_head *terms;
};
void parse_events__shrink_config_terms(void);
diff --git a/tools/perf/util/parse-events.y b/tools/perf/util/parse-events.y
index ffb4914142cf..8acb2c4ca711 100644
--- a/tools/perf/util/parse-events.y
+++ b/tools/perf/util/parse-events.y
@@ -494,7 +494,7 @@ opt_event_config:
start_terms: event_config
{
- struct parse_events_terms *data = _data;
+ struct parse_events_state *data = _data;
data->terms = $1;
}
next prev parent reply other threads:[~2017-08-17 17:22 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-08-16 22:01 Two minor perf patches preparing for Skylake server events Andi Kleen
2017-08-16 22:02 ` [PATCH 1/2] perf, tools, json: Support FCMask and PortMask Andi Kleen
2017-08-17 15:20 ` Arnaldo Carvalho de Melo
2017-08-22 10:23 ` [tip:perf/core] perf jevents: " tip-bot for Andi Kleen
2017-08-16 22:02 ` [PATCH 2/2] perf, tools: Avoid segfault on alias parse error Andi Kleen
2017-08-17 15:28 ` Arnaldo Carvalho de Melo
2017-08-17 15:34 ` Andi Kleen
2017-08-17 16:25 ` Arnaldo Carvalho de Melo
2017-08-17 17:02 ` Andi Kleen
2017-08-17 16:42 ` Arnaldo Carvalho de Melo
2017-08-17 17:04 ` Andi Kleen
2017-08-17 17:22 ` Arnaldo Carvalho de Melo [this message]
2017-08-22 7:23 ` Jiri Olsa
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=20170817172232.GF10891@kernel.org \
--to=acme@kernel.org \
--cc=ak@linux.intel.com \
--cc=andi@firstfloor.org \
--cc=jolsa@kernel.org \
--cc=linux-kernel@vger.kernel.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.