Messages in this thread | | | Date | Tue, 15 Mar 2022 11:53:22 +0530 | Subject | Re: [PATCH v6 10/12] perf tools: Improve IBS error handling | From | Ravi Bangoria <> |
| |
>> +static bool is_amd(const char *arch, const char *cpuid) >> +{ >> + return arch && !strcmp("x86", arch) && cpuid && strstarts(cpuid, "AuthenticAMD"); >> +} >> + >> +static bool is_amd_ibs(struct evsel *evsel) >> +{ >> + return evsel->core.attr.precise_ip || !strncmp(evsel->pmu_name, "ibs", 3); >> +} >> + >> int evsel__open_strerror(struct evsel *evsel, struct target *target, >> int err, char *msg, size_t size) >> { >> + struct perf_env *env = evsel__env(evsel); >> + const char *arch = perf_env__arch(env); >> + const char *cpuid = perf_env__cpuid(env); > > > This code dies for me on the latest tip.git because env = NULL and > perf_env_cpuid() is broken for NULL argument. > I don't quite know where this env global variable is set but I hope > there is a better way of doing this, maybe using > the evsel__env() function in the same util/evsel.c file. > > Similarly, the is_amd_ibs() suffers from a NULL pointer dereference > because evsel->pmu_name maybe NULL: > > $ perf record -e rc2 ..... > > causes a NULL pmu_name.
This should fix the issue:
@@ -2965,7 +2989,7 @@ int evsel__open_strerror(struct evsel *evsel, struct target *target,
struct perf_env *evsel__env(struct evsel *evsel) { - if (evsel && evsel->evlist) + if (evsel && evsel->evlist && evsel->evlist->env) return evsel->evlist->env; return &perf_env; }
Thanks, Ravi
| |