Skip to contentSkip to conversation

perf session: Invalidate last_match when removing threads from rb_tree

PATCH New Frederic Weisbecker 1 participant 1 message Jan 10, 2011 perf events

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 perf session: Invalidate last_match when removing threads from rb_tree

Hi,

This patch was applied few releases ago but lacked a tag for stable.

Is it possible to backport it for 2.6.35.x?

Thanks.

---

commit 70597f21f128b7dd6a2490078bea99d704b6f8c3

Author: Arnaldo Carvalho de Melo <[email protected]>
Date:   Mon Aug 2 18:59:28 2010 -0300

perf session: Invalidate last_match when removing threads from rb_tree

If we receive two PERF_RECORD_EXIT for the same thread, we can end up reusing session->last_match and trying to remove the thread twice from the rb_tree, causing a segfault, so invalidade last_match in perf_session__remove_thread.

Receiving two PERF_RECORD_EXIT for the same thread is a bug, but its a harmless one if we make the tool more robust, like this patch does.

Cc: Mike Galbraith <[email protected]>
Cc: Peter Zijlstra <[email protected]>
Cc: Stephane Eranian <[email protected]>
LKML-Reference: <new-submission>

---

tools/perf/util/session.c +1 -0
index 5d2fd52..fa9d652 100644
@@ -166,6 +166,7 @@ void perf_session__delete(struct perf_session *self)
 
 void perf_session__remove_thread(struct perf_session *self, struct thread *th)
 {
+	self->last_match = NULL;
 	rb_erase(&th->rb_node, &self->threads);
 	/*
 	 * We may have references to this thread, for instance in some hist_entry