• Ian Rogers's avatar
    perf symbols: Factor out annotation init/exit · 4f74f187
    Ian Rogers authored
    The exit function fixes a memory leak with the src field as detected by
    leak sanitizer. An example of which is:
    
    Indirect leak of 25133184 byte(s) in 207 object(s) allocated from:
        #0 0x7f199ecfe987 in __interceptor_calloc libsanitizer/asan/asan_malloc_linux.cpp:154
        #1 0x55defe638224 in annotated_source__alloc_histograms util/annotate.c:803
        #2 0x55defe6397e4 in symbol__hists util/annotate.c:952
        #3 0x55defe639908 in symbol__inc_addr_samples util/annotate.c:968
        #4 0x55defe63aa29 in hist_entry__inc_addr_samples util/annotate.c:1119
        #5 0x55defe499a79 in hist_iter__report_callback tools/perf/builtin-report.c:182
        #6 0x55defe7a859d in hist_entry_iter__add util/hist.c:1236
        #7 0x55defe49aa63 in process_sample_event tools/perf/builtin-report.c:315
        #8 0x55defe731bc8 in evlist__deliver_sample util/session.c:1473
        #9 0x55defe731e38 in machines__deliver_event util/session.c:1510
        #10 0x55defe732a23 in perf_session__deliver_event util/session.c:1590
        #11 0x55defe72951e in ordered_events__deliver_event util/session.c:183
        #12 0x55defe740082 in do_flush util/ordered-events.c:244
        #13 0x55defe7407cb in __ordered_events__flush util/ordered-events.c:323
        #14 0x55defe740a61 in ordered_events__flush util/ordered-events.c:341
        #15 0x55defe73837f in __perf_session__process_events util/session.c:2390
        #16 0x55defe7385ff in perf_session__process_events util/session.c:2420
        ...
    Signed-off-by: default avatarIan Rogers <irogers@google.com>
    Acked-by: default avatarNamhyung Kim <namhyung@kernel.org>
    Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
    Cc: Ingo Molnar <mingo@redhat.com>
    Cc: James Clark <james.clark@arm.com>
    Cc: Jiri Olsa <jolsa@redhat.com>
    Cc: Kajol Jain <kjain@linux.ibm.com>
    Cc: Mark Rutland <mark.rutland@arm.com>
    Cc: Martin Liška <mliska@suse.cz>
    Cc: Peter Zijlstra <peterz@infradead.org>
    Cc: Stephane Eranian <eranian@google.com>
    Link: https://lore.kernel.org/r/20211112035124.94327-3-irogers@google.comSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
    4f74f187
annotate.c 79.7 KB