[PATCH] perf lock: fix segfault with info subcommand following move to libtraceevent

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]


Running 'perf lock info' on a "random" perf.data file crashes:

0  0x00000000004a5618 in __parse_common (pevent=0x0, data=0x0, size=0xa0, offset=0x9c, name=
    0x556e02 "common_type") at /opt/sw/ahern/kernels/kernel.git/tools/lib/traceevent/event-parse.c:2851
1  0x00000000004a56a7 in trace_parse_common_type (pevent=0x0, data=0x0)
    at /opt/sw/ahern/kernels/kernel.git/tools/lib/traceevent/event-parse.c:2861
2  0x00000000004a7e42 in pevent_data_type (pevent=0x0, rec=0x7fffffffddf0)
    at /opt/sw/ahern/kernels/kernel.git/tools/lib/traceevent/event-parse.c:3952
3  0x0000000000473f37 in trace_parse_common_type (data=0x0) at util/trace-event-parse.c:158
4  0x00000000004376cd in process_raw_event (data=0x0, cpu=-1, timestamp=533548521126805, thread=
    0x918450) at builtin-lock.c:727
5  0x0000000000437df4 in process_sample_event (tool=0x7ab300, event=0x7ffff7ff9dd8, sample=
    0x7fffffffdf60, evsel=0x917d90, machine=0x9161c0) at builtin-lock.c:863
6  0x0000000000470d04 in perf_session_deliver_event (session=0x916160, event=0x7ffff7ff9dd8, sample=
    0x7fffffffdf60, tool=0x7ab300, file_offset=11736) at util/session.c:977
7  0x000000000047024a in flush_sample_queue (s=0x916160, tool=0x7ab300) at util/session.c:679
8  0x0000000000471ba9 in __perf_session__process_events (session=0x916160, data_offset=400, data_size=
    11576, file_size=11976, tool=0x7ab300) at util/session.c:1363
9  0x0000000000471c5e in perf_session__process_events (self=0x916160, tool=0x7ab300)
    at util/session.c:1379
10 0x0000000000437e80 in read_events () at builtin-lock.c:880
11 0x0000000000438275 in cmd_lock (argc=0, argv=0x7fffffffe420, prefix=0x0) at builtin-lock.c:10

In this case the data file has cycles events, not traces and hence nothing
to do with lock tracepoints. Nonetheless, perf-lock should not crash. The
crash started with commit aaf045f72335653b24784d6042be8e4aee114403 - ie.,
the move to libtraceevent.

With this patch you get the more user friendly:
$ perf lock info
  Fatal: Unknown type of information

Signed-off-by: David Ahern <dsahern@xxxxxxxxx>
CC: Arnaldo Carvalho de Melo <acme@xxxxxxxxxx>
Cc: Ingo Molnar <mingo@xxxxxxxxxx>
Cc: Steven Rostedt <rostedt@xxxxxxxxxxx>
---
 tools/perf/builtin-lock.c |    3 +++
 1 file changed, 3 insertions(+)

diff --git a/tools/perf/builtin-lock.c b/tools/perf/builtin-lock.c
index fd53319..55f7961 100644
--- a/tools/perf/builtin-lock.c
+++ b/tools/perf/builtin-lock.c
@@ -877,6 +877,9 @@ static int read_events(void)
 	if (!session)
 		die("Initializing perf session failed\n");
 
+	if (!perf_session__has_traces(session, "lock record"))
+		exit(1);
+
 	return perf_session__process_events(session, &eops);
 }
 
-- 
1.7.10.1

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[Other Archives]     [Linux Kernel Newbies]     [Linux Driver Development]     [Linux Kbuild]     [Fedora Kernel]     [Linux Kernel Testers]     [Linux SH]     [Linux Omap]     [Linux Tape]     [Linux Input]     [Linux Kernel Janitors]     [Linux Kernel Packagers]     [Linux Doc]     [Linux Man Pages]     [Linux API]     [Linux Memory Management]     [Linux Modules]     [Linux Standards]     [Kernel Announce]     [Netdev]     [Git]     [Linux PCI]     Linux CAN Development     [Linux I2C]     [Linux RDMA]     [Linux NUMA]     [Netfilter]     [Netfilter Devel]     [SELinux]     [Bugtraq]     [FIO]     [Linux Perf Users]     [Linux Serial]     [Linux PPP]     [Linux ISDN]     [Linux Next]     [Kernel Stable Commits]     [Linux Tip Commits]     [Kernel MM Commits]     [Linux Security Module]     [AutoFS]     [Filesystem Development]     [Ext3 Filesystem]     [Linux bcache]     [Ext4 Filesystem]     [Linux BTRFS]     [Linux CEPH Filesystem]     [Linux XFS]     [XFS]     [Linux NFS]     [Linux CIFS]     [Ecryptfs]     [Linux NILFS]     [Linux Cachefs]     [Reiser FS]     [Initramfs]     [Linux FB Devel]     [Linux OpenGL]     [DRI Devel]     [Fastboot]     [Linux RT Users]     [Linux RT Stable]     [eCos]     [Corosync]     [Linux Clusters]     [LVS Devel]     [Hot Plug]     [Linux Virtualization]     [KVM]     [KVM PPC]     [KVM ia64]     [Linux Containers]     [Linux Hexagon]     [Linux Cgroups]     [Util Linux]     [Wireless]     [Linux Bluetooth]     [Bluez Devel]     [Ethernet Bridging]     [Embedded Linux]     [Barebox]     [Linux MMC]     [Linux IIO]     [Sparse]     [Smatch]     [Linux Arch]     [x86 Platform Driver]     [Linux ACPI]     [Linux IBM ACPI]     [LM Sensors]     [CPU Freq]     [Linux Power Management]     [Linmodems]     [Linux DCCP]     [Linux SCTP]     [ALSA Devel]     [Linux USB]     [Linux PA RISC]     [Linux Samsung SOC]     [MIPS Linux]     [IBM S/390 Linux]     [ARM Linux]     [ARM Kernel]     [ARM MSM]     [Tegra Devel]     [Sparc Linux]     [Linux Security]     [Linux Sound]     [Linux Media]     [Video 4 Linux]     [Linux IRDA Users]     [Linux for the blind]     [Linux RAID]     [Linux ATA RAID]     [Device Mapper]     [Linux SCSI]     [SCSI Target Devel]     [Linux SCSI Target Infrastructure]     [Linux IDE]     [Linux SMP]     [Linux AXP]     [Linux Alpha]     [Linux M68K]     [Linux ia64]     [Linux 8086]     [Linux x86_64]     [Linux Config]     [Linux Apps]     [Linux MSDOS]     [Linux X.25]     [Linux Crypto]     [DM Crypt]     [Linux Trace Users]     [Linux Btrace]     [Linux Watchdog]     [Utrace Devel]     [Linux C Programming]     [Linux Assembly]     [Dash]     [DWARVES]     [Hail Devel]     [Linux Kernel Debugger]     [Linux gcc]     [Gcc Help]     [X.Org]     [Wine]

Add to Google Powered by Linux

[Older Kernel Discussion]     [Yosemite National Park Forum]     [Large Format Photos]     [Gimp]     [Yosemite Photos]     [Stuff]