aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJiri Olsa <jolsa@redhat.com>2012-04-16 14:42:51 -0400
committerArnaldo Carvalho de Melo <acme@redhat.com>2012-05-04 10:53:22 -0400
commit9389a46043c8f091dc8f8d8e25a5c1355f8bcc9b (patch)
tree54c4581ee79eea4e51530f9b423b8f7e825140e4
parentdc41b9b8f02dbe2228ae787d525dac43beebb7fa (diff)
perf session: Fail on processing event with unknown size
Currently if we cannot decide the size of the event, we guess next event possition by: "... check alignment, and increment a single u64 in the hope to catch on again 'soon'" This usually ends up with segfault or endless loop. It's better to admit the failure right away, then pretend nothing happened. It makes the life easier ;) Signed-off-by: Jiri Olsa <jolsa@redhat.com> Acked-by: Peter Zijlstra <a.p.zijlstra@chello.nl> Cc: Corey Ashford <cjashfor@linux.vnet.ibm.com> Cc: Frederic Weisbecker <fweisbec@gmail.com> Cc: Ingo Molnar <mingo@elte.hu> Cc: Paul Mackerras <paulus@samba.org> Cc: Peter Zijlstra <a.p.zijlstra@chello.nl> Link: http://lkml.kernel.org/r/20120416184251.GA11503@m.brq.redhat.com Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
-rw-r--r--tools/perf/util/session.c30
1 files changed, 9 insertions, 21 deletions
diff --git a/tools/perf/util/session.c b/tools/perf/util/session.c
index 9412e3b05f68..f992ae3c7e30 100644
--- a/tools/perf/util/session.c
+++ b/tools/perf/util/session.c
@@ -1100,16 +1100,10 @@ more:
1100 } 1100 }
1101 1101
1102 if ((skip = perf_session__process_event(self, &event, tool, head)) < 0) { 1102 if ((skip = perf_session__process_event(self, &event, tool, head)) < 0) {
1103 dump_printf("%#" PRIx64 " [%#x]: skipping unknown header type: %d\n", 1103 pr_err("%#" PRIx64 " [%#x]: failed to process type: %d\n",
1104 head, event.header.size, event.header.type); 1104 head, event.header.size, event.header.type);
1105 /* 1105 err = -EINVAL;
1106 * assume we lost track of the stream, check alignment, and 1106 goto out_err;
1107 * increment a single u64 in the hope to catch on again 'soon'.
1108 */
1109 if (unlikely(head & 7))
1110 head &= ~7ULL;
1111
1112 size = 8;
1113 } 1107 }
1114 1108
1115 head += size; 1109 head += size;
@@ -1218,17 +1212,11 @@ more:
1218 1212
1219 if (size == 0 || 1213 if (size == 0 ||
1220 perf_session__process_event(session, event, tool, file_pos) < 0) { 1214 perf_session__process_event(session, event, tool, file_pos) < 0) {
1221 dump_printf("%#" PRIx64 " [%#x]: skipping unknown header type: %d\n", 1215 pr_err("%#" PRIx64 " [%#x]: failed to process type: %d\n",
1222 file_offset + head, event->header.size, 1216 file_offset + head, event->header.size,
1223 event->header.type); 1217 event->header.type);
1224 /* 1218 err = -EINVAL;
1225 * assume we lost track of the stream, check alignment, and 1219 goto out_err;
1226 * increment a single u64 in the hope to catch on again 'soon'.
1227 */
1228 if (unlikely(head & 7))
1229 head &= ~7ULL;
1230
1231 size = 8;
1232 } 1220 }
1233 1221
1234 head += size; 1222 head += size;