I spent some time on this, as the tests in utest/ were segfaulting.
Turns out this is an endianness issue in libtraceeevent.
In libtraceevent/src/event_parse.c, we have:

```
/**
 * tep_alloc - create a tep handle
 */
struct tep_handle *tep_alloc(void)
{
        struct tep_handle *tep = calloc(1, sizeof(*tep));

        if (tep) {
                tep->ref_count = 1;
                tep->host_bigendian = tep_is_bigendian();
        }

        return tep;
}
```

So on s390x, tep->host_bigendian is TEP_BIG_ENDIAN, but
tep->file_bigendian stays the default value (TEP_LITTLE_ENDIAN)

Then in libtracefs/src/kbuffer_parse.c, we have:

```
enum {
        KBUFFER_FL_HOST_BIG_ENDIAN      = (1<<0),
        KBUFFER_FL_BIG_ENDIAN           = (1<<1),
        KBUFFER_FL_LONG_8               = (1<<2),
        KBUFFER_FL_OLD_FORMAT           = (1<<3),
};

#define ENDIAN_MASK (KBUFFER_FL_HOST_BIG_ENDIAN | KBUFFER_FL_BIG_ENDIAN)

...

static int do_swap(struct kbuffer *kbuf)
{
        return ((kbuf->flags & KBUFFER_FL_HOST_BIG_ENDIAN) + kbuf->flags) &
                ENDIAN_MASK;
}
```

kbuf->flags is populated based off the tep_handle object. So the tests
fail because libtraceevent thinks the files it opens are stored in
little endian format, while actually it is the other way round.

My fix was to change `tep->host_bigendian = tep_is_bigendian();` to
`tep->host_bigendian = tep->file_bigendian = tep_is_bigendian();`

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)

I am not sure if this must go upstream as well, and even if this would
be the right fix. But it does fix the tests

```
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
```

-- 
You received this bug notification because you are a member of Ubuntu
Bugs, which is subscribed to Ubuntu.
https://bugs.launchpad.net/bugs/2062118

Title:
  autopkgtests fail on s390x (segfault)

To manage notifications about this bug go to:
https://bugs.launchpad.net/ubuntu-z-systems/+bug/2062118/+subscriptions


-- 
ubuntu-bugs mailing list
ubuntu-bugs@lists.ubuntu.com
https://lists.ubuntu.com/mailman/listinfo/ubuntu-bugs

Reply via email to