Messages in this thread Patch in this message | | | Date | Mon, 06 May 2013 18:05:30 -0600 | From | David Ahern <> | Subject | Re: [PATCH] perf record: handle death by SIGTERM |
| |
On 5/6/13 4:40 PM, Stephane Eranian wrote: > This is a good fix. I have run into this infinite loop in perf report > many times.
The perf_file_header could use an 'I am sane' bit which is only set when the file is closed properly. Perhaps we could overload the magic field like this:
diff --git a/tools/perf/util/header.c b/tools/perf/util/header.c index 326068a..cd9fad6 100644 --- a/tools/perf/util/header.c +++ b/tools/perf/util/header.c @@ -2364,7 +2364,6 @@ out_err_write: }
f_header = (struct perf_file_header){ - .magic = PERF_MAGIC, .size = sizeof(f_header), .attr_size = sizeof(f_attr), .attrs = { @@ -2382,6 +2381,8 @@ out_err_write: };
memcpy(&f_header.adds_features, &header->adds_features, sizeof(header->adds_features)); + if (at_exit) + f_header.magic = PERF_MAGIC,
lseek(fd, 0, SEEK_SET); err = do_write(fd, &f_header, sizeof(f_header)); The perf magic is only written when the file is closed properly. In Mike's case you end up with the message (which can be enhanced)
magic/endian check failed incompatible file format (rerun with -v to learn more)
which is better than an infinite loop.
David
| |