All of lore.kernel.org
 help / color / mirror / Atom feed
From: Wang Nan <wangnan0@huawei.com>
To: Arnaldo Carvalho de Melo <acme@kernel.org>,
	Jiri Olsa <jolsa@redhat.com>, Namhyung Kim <namhyung@kernel.org>
Cc: Li Zefan <lizefan@huawei.com>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>
Subject: [BUG] perf report: segfault when annotate kernel module.
Date: Thu, 2 Apr 2015 16:59:51 +0800	[thread overview]
Message-ID: <551D0507.5050107@huawei.com> (raw)

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!


                 reply	other threads:[~2015-04-02  9:00 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=551D0507.5050107@huawei.com \
    --to=wangnan0@huawei.com \
    --cc=acme@kernel.org \
    --cc=jolsa@redhat.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=lizefan@huawei.com \
    --cc=namhyung@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.