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 <[email protected]> Tested-by: Arnaldo Carvalho de Melo <[email protected]> Acked-by: Jiri Olsa <[email protected]> Cc: Ian Rogers <[email protected]> Cc: Jin Yao <[email protected]> Cc: Namhyung Kim <[email protected]> Cc: Song Liu <[email protected]> Link: http://lore.kernel.org/lkml/[email protected] Signed-off-by: Arnaldo Carvalho de Melo <[email protected]>
1 parent d3c0314 commit e0560ba

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

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)