This patch initialises the file endianness to the same value as host endianness. Without this, the file endianness is set to little endian by default, which results in segfaults of libtracefs testsuite on big endian architectures (libtracefs uses libtracevent, and my investigating led to this patch). We can make a default assumption that the host and FS endianness is same. If it is different, the user must set the correct endianness using the event-parse-api (tep_set_file_bigendian) After applying my fix, the run summary of utest/trace-utest of libtracefs: Run Summary: Type Total Ran Passed Failed Inactive suites 1 1 n/a 0 0 tests 36 36 35 1 0 asserts 16407066 16407066 16407064 2 n/a Elapsed time = 22.623 seconds Signed-off-by: Pragyansh Chaturvedi <pragyansh.chaturvedi@xxxxxxxxxxxxx> Cc: Steven Rostedt <rostedt@xxxxxxxxxxx> --- src/event-parse.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/event-parse.c b/src/event-parse.c index 0427061..200e59a 100644 --- a/src/event-parse.c +++ b/src/event-parse.c @@ -8501,6 +8501,14 @@ struct tep_handle *tep_alloc(void) if (tep) { tep->ref_count = 1; tep->host_bigendian = tep_is_bigendian(); + + /* + * We can make the following safe assumption + * for the default case. Else it leaves the + * file endianness as little endian and breaks + * things on big endian architectures. + */ + tep->file_bigendian = tep->host_bigendian; } return tep; -- 2.43.0