Hi folks,
I hit a segfault when try to analysis a perf.data generated in an aarch 64 board.
I tried execute perf report on x86 and arm64, both of them hit similar segfault:
$ perf report -i ./buggy/perf.data --objdump=/path/to/aarch64-oe-linux-objdump --kallsyms /path/to/kallsyms
perf: Segmentation fault
-------- backtrace --------
/home/user/perf[0x503478]
/lib64/libc.so.6(+0x3545f)[0x7f5e6944b45f]
/home/user/perf[0x499b56]
/home/user/perf(dso__load_kallsyms+0x13c)[0x49b56c]
/home/user/perf(dso__load+0x72e)[0x49c21e]
/home/user/perf(map__load+0x6e)[0x4ae9ee]
/home/user/perf(thread__find_addr_map+0x24c)[0x47deec]
/home/user/perf(perf_event__preprocess_sample+0x88)[0x47e238]
/home/user/perf[0x43ad02]
/home/user/perf[0x4b55bc]
/home/user/perf(ordered_events__flush+0x1a9)[0x4b58c9]
/home/user/perf(perf_session__process_events+0x407)[0x4b42d7]
/home/user/perf(cmd_report+0xf11)[0x43bfc1]
/home/user/perf[0x474702]
/home/user/perf(main+0x5f5)[0x42de95]
/lib64/libc.so.6(__libc_start_main+0xf4)[0x7f5e69437bd4]
/home/user/perf[0x42dfc4]
I did some debugging and found the problem is raised at dso__load_kcore:
static int dso__load_kcore(struct dso *dso, struct map *map,
const char *kallsyms_filename)
{
struct map_groups *kmaps = map__kmap(map)->kmaps; // kmap is NULL here
struct machine *machine = kmaps->machine; // segfault.
...
}
Then I realised that if a struct map is created by machine__new_module with map__new2,
the map__kmap(map) is never set. However, if I set
map->map_ip = map->unmap_ip = identity__map_ip;
kmap = map__kmap(map);
kmap->kmaps = &machine->kmaps;
in machine__new_module like in __machine__create_kernel_maps, I hit another problem:
*** Error in `/home/user/perf': free(): invalid next size (normal): 0x0000000002411a60 ***
======= Backtrace: =========
/lib64/libc.so.6(+0x6eeef)[0x7f2ed502feef]
/lib64/libc.so.6(+0x78cae)[0x7f2ed5039cae]
/lib64/libc.so.6(+0x79987)[0x7f2ed503a987]
/home/user/perf(dso__data_fd+0x456)[0x496be6]
/home/user/perf(dso__type+0x1a)[0x4987ea]
/home/user/perf(vdso__dso_findnew+0x7d)[0x4d2cbd]
/home/user/perf(map__new+0x2c3)[0x4ae7c3]
/home/user/perf[0x4a90fa]
/home/user/perf(machine__process_mmap2_event+0xc1)[0x4acbf1]
/home/user/perf[0x4b1fec]
/home/user/perf(perf_session__process_events+0x3bf)[0x4b45ff]
/home/user/perf(cmd_report+0xf12)[0x43bfc2]
/home/user/perf[0x474703]
/home/user/perf(main+0x5f6)[0x42de96]
/lib64/libc.so.6(__libc_start_main+0xf5)[0x7f2ed4fe2bd5]
/home/user/perf[0x42dfc5]
======= Memory map: ========
...
Does anyone has any idea on it?
Thank you!