`g_variant_byteswap` sometimes doesn't byteswap
I don't have a minimal reproducer yet, though in rpm-ostree (which is used by coreos-assembler to build Fedora CoreOS), we sometimes observe our metadata not having its values byteswapped after calling g_variant_byteswap
:
https://github.com/coreos/rpm-ostree/issues/1734#issuecomment-640885130
Relevant section of code is https://github.com/coreos/rpm-ostree/blob/fdb63ce699bb3438828e8a805a628704fba9b393/src/app/rpmostree-composeutil.c#L366-L372:
if (G_BYTE_ORDER != G_BIG_ENDIAN)
{
GVariant *swapped = g_variant_byteswap (ret);
GVariant *orig = ret;
ret = swapped;
g_variant_unref (orig);
}
In my tests, it seems to only happen around 1 out of 5 times (see the linked comment for more details), which indicates to me there's possibly some undefined behaviour going on here.
Will try to get a smaller reproducer and make sure it reproduces on git master (currently using 2.64).