Re: [PATCH] perf kvm: fix segfault with default guest arguments

From: David Ahern
Date: Thu Jun 28 2012 - 10:52:59 EST


On 6/28/12 8:44 AM, Arnaldo Carvalho de Melo wrote:
Em Sun, Jun 24, 2012 at 10:41:26PM -0600, David Ahern escreveu:
File generated with:
$ perf kvm --host --guest --guestkallsyms=/tmp/guest-kallsyms
--guestmodules=/tmp/guest-modules record -a

The report command:
$ perf kvm --host --guest --guestkallsyms=/tmp/guest-kallsyms
--guestmodules=/tmp/guest-modules report

dies with a SEGFAULT:
Program received signal SIGSEGV, Segmentation fault.
0x000000000046dd7b in machine__mmap_name (self=0x0, bf=0x7fffffffbd20 "q\021", size=4096) at util/map.c:715
715 snprintf(bf, size, "[%s.%d]", "guest.kernel.kallsyms", self->pid);

(gdb) bt
0 0x000000000046dd7b in machine__mmap_name (self=0x0, bf=0x7fffffffbd20 "q\021", size=4096) at util/map.c:715
1 0x0000000000444161 in perf_event__process_kernel_mmap (tool=0x7fffffffdd80, event=0x7ffff7fb4120, machine=0x0) at util/event.c:562

I think that this should be handled at perf_event__process_kernel_mmap,
i.e. tools can conceivably handle this situation in their specific
handlers.

@@ -976,6 +976,8 @@ static int perf_session_deliver_event(struct perf_session *session,
}
return tool->sample(tool, event, sample, evsel, machine);
case PERF_RECORD_MMAP:
+ if (machine == NULL)
+ return 0;
return tool->mmap(tool, event, sample, machine);

- Arnaldo


Ok. Doing it in perf_session_deliver_event makes it consistent with the SAMPLE case.

David
--
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/