From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752279AbbDCJIG (ORCPT ); Fri, 3 Apr 2015 05:08:06 -0400 Received: from mx1.redhat.com ([209.132.183.28]:36917 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751780AbbDCJIA (ORCPT ); Fri, 3 Apr 2015 05:08:00 -0400 Date: Fri, 3 Apr 2015 11:07:42 +0200 From: Jiri Olsa To: Wang Nan Cc: namhyung@kernel.org, jolsa@kernel.org, acme@redhat.com, mingo@kernel.org, linux-kernel@vger.kernel.org, pi3orama@163.com Subject: Re: [PATCH v2] perf: report/annotate: fix segfault problem. Message-ID: <20150403090742.GA5571@krava.brq.redhat.com> References: <1428040585-52586-1-git-send-email-wangnan0@huawei.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1428040585-52586-1-git-send-email-wangnan0@huawei.com> User-Agent: Mutt/1.5.23 (2014-03-12) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Apr 03, 2015 at 05:56:25AM +0000, Wang Nan wrote: > perf report and perf annotate are easy to trigger segfault if trace data > contain kernel module information like this: > > # perf report -D -i ./perf.data > ... > 0 0 0x188 [0x50]: PERF_RECORD_MMAP -1/0: [0xffffffbff1018000(0xf068000) @ 0]: x [test_module] > ... > > # perf report -i ./perf.data --objdump=/path/to/objdump --kallsyms=/path/to/kallsyms > > perf: Segmentation fault > -------- backtrace -------- > /path/to/perf[0x503478] > /lib64/libc.so.6(+0x3545f)[0x7fb201f3745f] > /path/to/perf[0x499b56] > /path/to/perf(dso__load_kallsyms+0x13c)[0x49b56c] > /path/to/perf(dso__load+0x72e)[0x49c21e] > /path/to/perf(map__load+0x6e)[0x4ae9ee] > /path/to/perf(thread__find_addr_map+0x24c)[0x47deec] > /path/to/perf(perf_event__preprocess_sample+0x88)[0x47e238] > /path/to/perf[0x43ad02] > /path/to/perf[0x4b55bc] > /path/to/perf(ordered_events__flush+0xca)[0x4b57ea] > /path/to/perf[0x4b1a01] > /path/to/perf(perf_session__process_events+0x3be)[0x4b428e] > /path/to/perf(cmd_report+0xf11)[0x43bfc1] > /path/to/perf[0x474702] > /path/to/perf(main+0x5f5)[0x42de95] > /lib64/libc.so.6(__libc_start_main+0xf4)[0x7fb201f23bd4] > /path/to/perf[0x42dfc4] > > This is because __kmod_path__parse regard '[' leading name as kernel > instead of kernel module. The DSO will then be passed to > dso__load_kernel_sym() then dso__load_kcore() because of --kallsyms > argument. The segfault is triggered because the kmap structure is not > initialized. > > Although in --vmlinux case such segfault can be avoided, the symbols in > the kernel module are unable to be retrived since the attribute of DSO > is incorrect. > > This patch fixes __kmod_path__parse, make it regard names like > '[test_module]' as kernel module. hum, I need to go through that backtrace first.. but could you also update the tests/kmod-path.c, so it's obvious what's the output of __kmod_path__parse for [test_module] thanks, jirka