Skip to contentSkip to conversation

perf annotate: Fix segmentation fault

tip:perfcounters/urgent tip-bot for Ingo Molnar 1 participant 1 message Aug 18, 2009 perf events

lore
Share & tools
lore
#0 lore raw
Commit-ID:  15f3fa4e7f608c5ce19187b3b4a953222fdfa751
Gitweb:     http://git.kernel.org/tip/15f3fa4e7f608c5ce19187b3b4a953222fdfa751
Author:     Ingo Molnar <[email protected]>
AuthorDate: Tue, 18 Aug 2009 13:52:28 +0200
Committer:  Ingo Molnar <[email protected]>
CommitDate: Tue, 18 Aug 2009 14:00:52 +0200

perf annotate: Fix segmentation fault

Linus reported this perf annotate segfault:

[torvalds@nehalem git]$ perf annotate unmap_vmas Segmentation fault

#0 map__clone (self=<value optimized out>) at builtin-annotate.c:236 #1 thread__fork (self=<value optimized out>) at builtin-annotate.c:372

The bug here was that builtin-annotate.c was a copy of builtin-report.c and a threading related fix to builtin-report.c didnt get propagated to builtin-annotate.c ...

Cc Peter Zijlstra <[email protected]>
Cc Mike Galbraith <[email protected]>
Cc Paul Mackerras <[email protected]>
Cc Arnaldo Carvalho de Melo <[email protected]>
Cc Frederic Weisbecker <[email protected]>

LKML-Reference: <new-submission>

---
 tools/perf/builtin-annotate.c |    7 +++++++
 1 files changed, 7 insertions(+), 0 deletions(-)
tools/perf/builtin-annotate.c +7 -0
index 1dba568..343e7b1 100644
@@ -980,6 +980,13 @@ process_fork_event(event_t *event, unsigned long offset, unsigned long head)
 		(void *)(long)(event->header.size),
 		event->fork.pid, event->fork.ppid);
 
+	/*
+	 * A thread clone will have the same PID for both
+	 * parent and child.
+	 */
+	if (thread == parent)
+		return 0;
+
 	if (!thread || !parent || thread__fork(thread, parent)) {
 		dprintf("problem processing PERF_EVENT_FORK, skipping event.\n");
 		return -1;