Skip to contentSkip to conversation

perf: avoid structure size confusion by using a fixed size

PATCH New Arjan van de Ven 1 participant 1 message Jul 21, 2009 perf events

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 perf: avoid structure size confusion by using a fixed size

From f9edcb31f1d4935fa0a8fc0891c90d6e0174fcae Mon Sep 17 00:00:00 2001
From: Arjan van de Ven <[email protected]>
Date: Mon, 20 Jul 2009 22:54:26 -0700
Subject: [PATCH] perf: avoid structure size confusion by using a fixed size

for some reason, this structure gets compiled as 36 bytes in some files (the ones that alloacte it) but 40 bytes in others (the ones that use it). The cause is an off_t type that gets a different size in different compilation units for some yet-to-be-explained reason.

But the effect is disasterous; the size/offset members of the struct are at different offsets, and result in mostly complete garbage. The parser in perf is so robust that this all gets hidden, and after skipping an certain amount of samples, it recovers.... so this bug is not normally noticed.

... except when you want every sample to be exact.

Fix this by just using an explicitly sized type.

---
 tools/perf/util/header.h |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
tools/perf/util/header.h +1 -1
index b5ef53a..bf28044 100644
@@ -16,7 +16,7 @@ struct perf_header {
 	int frozen;
 	int attrs, size;
 	struct perf_header_attr **attr;
-	off_t attr_offset;
+	s64 attr_offset;
 	u64 data_offset;
 	u64 data_size;
 };
Signature · 1 line
1.6.0.6