Skip to content

Commit e0560ba

Browse files
Ravi Bangoriaacmel
authored andcommitted
perf annotate: Fix segfault with source toggle
While rendering annotate browser from perf report tui, we keep track of total number of lines(asm + source) in annotation->nr_entries and total number of asm lines in annotation->nr_asm_entries. But we don't reset them before starting. Thus if user annotates same function multiple times, we restart incrementing these fields with old values. This causes a segfault when user tries to toggle source code after annotating same function multiple times. Fix it. Signed-off-by: Ravi Bangoria <ravi.bangoria@linux.ibm.com> Tested-by: Arnaldo Carvalho de Melo <acme@redhat.com> Acked-by: Jiri Olsa <jolsa@redhat.com> Cc: Ian Rogers <irogers@google.com> Cc: Jin Yao <yao.jin@linux.intel.com> Cc: Namhyung Kim <namhyung@kernel.org> Cc: Song Liu <songliubraving@fb.com> Link: http://lore.kernel.org/lkml/20200204045233.474937-5-ravi.bangoria@linux.ibm.com Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
1 parent d3c0314 commit e0560ba

1 file changed

Lines changed: 2 additions & 0 deletions

File tree

tools/perf/util/annotate.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2621,6 +2621,8 @@ void annotation__set_offsets(struct annotation *notes, s64 size)
26212621
struct annotation_line *al;
26222622

26232623
notes->max_line_len = 0;
2624+
notes->nr_entries = 0;
2625+
notes->nr_asm_entries = 0;
26242626

26252627
list_for_each_entry(al, &notes->src->source, node) {
26262628
size_t line_len = strlen(al->line);

0 commit comments

Comments
 (0)