Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 947903 - app-arch/xz-utils-5.6.3: generates corrupt compressed data on big endian arm64
Summary: app-arch/xz-utils-5.6.3: generates corrupt compressed data on big endian arm64
Status: RESOLVED FIXED
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: Current packages (show other bugs)
Hardware: ARM64 Linux
: Normal normal
Assignee: Gentoo's Team for Core System packages
URL:
Whiteboard:
Keywords: PATCH
Depends on:
Blocks:
 
Reported: 2025-01-11 13:56 UTC by Marcus Comstedt
Modified: 2025-01-24 12:24 UTC (History)
2 users (show)

See Also:
Package list:
Runtime testing required: ---


Attachments
Patch to fix the data corruption (lzma_memcmplen_aarch64_be.patch,868 bytes, patch)
2025-01-11 16:41 UTC, Marcus Comstedt
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Marcus Comstedt 2025-01-11 13:56:31 UTC
When building app-arch/xz-utils-5.6.3 on aarch64_be, the resulting xz binary
produces corrupt data.  Simple example:

momoka_be:~% echo "xxxxxxxx" | xz -c | xz -cd > /dev/null
xz: (stdin): Compressed data is corrupt
momoka_be:~% 

The generated compressed data in this case is:

000000 fd 37 7a 58 5a 00 00 04 e6 d6 b4 46 04 c0 0f 09
000010 21 01 16 00 00 00 00 00 00 00 00 00 f2 8b 5d 05
000020 e0 00 08 00 07 5d 00 3c 68 e5 8c 00 00 00 00 00
000030 1f 85 df 6e 40 e9 79 a4 00 01 2b 09 e6 f0 2a 2f
000040 1f b6 f3 7d 01 00 00 00 00 04 59 5a

The correct output (generated on big endian ppc64 instead) is:

000000 fd 37 7a 58 5a 00 00 04 e6 d6 b4 46 04 c0 0f 09
000010 21 01 16 00 00 00 00 00 00 00 00 00 f2 8b 5d 05
000020 e0 00 08 00 07 5d 00 3c 6a 7e 80 00 00 00 00 00
000030 1f 85 df 6e 40 e9 79 a4 00 01 2b 09 e6 f0 2a 2f
000040 1f b6 f3 7d 01 00 00 00 00 04 59 5a

Only 3 bytes at offset 0x28 differ.

The problem can also be seen when enabling FEATURES=test:

============================================================================
Testsuite summary for XZ Utils 5.6.3
============================================================================
# TOTAL: 19
# PASS:  17
# SKIP:  0
# XFAIL: 0
# FAIL:  2
# XPASS: 0
# ERROR: 0
============================================================================

Note that the issue also prevents "autopoint" from working, since gettext's /usr/share/gettext/archive.dir.tar.xz becomes corrupt.  This causes build fails in multiple packages, and was how I initially noticed the problem.

Reproducible: Always

Steps to Reproduce:
1.FEATURES=test emerge -1 xz-utils
2.
3.
Actual Results:  
Two tests fail, test_compress_generated_random and test_compress_generated_text

Expected Results:  
All tests pass, like on powerpc

Portage 3.0.65 (python 3.12.7-final-0, default/linux/arm64/23.0/split-usr/big-endian, gcc-13, glibc-2.39-r6, 6.6.47 aarch64_be)
=================================================================
System uname: Linux-6.6.47-aarch64_be-with-glibc2.39
KiB Mem:     6081348 total,   4891160 free
KiB Swap:          0 total,         0 free
Timestamp of repository gentoo: Fri, 03 Jan 2025 14:30:00 +0000
Head commit of repository gentoo: 0a25b84cd8517260ec57b6d985f980775f2ee342
sh bash 5.2_p37
ld GNU ld (Gentoo 2.42 p3) 2.42.0
app-misc/pax-utils:        1.3.8::gentoo
app-shells/bash:           5.2_p37::gentoo
dev-build/autoconf:        2.71-r7::gentoo, 2.72-r1::gentoo
dev-build/automake:        1.16.5-r2::gentoo
dev-build/cmake:           3.30.2::gentoo
dev-build/libtool:         2.4.7-r4::gentoo
dev-build/make:            4.4.1-r100::gentoo
dev-build/meson:           1.5.1::gentoo
dev-lang/perl:             5.40.0::gentoo
dev-lang/python:           3.11.10_p1::gentoo, 3.12.7_p1::gentoo
sys-apps/baselayout:       2.17::gentoo
sys-apps/openrc:           0.55.1::gentoo
sys-apps/sandbox:          2.39::gentoo
sys-devel/binutils:        2.42-r1::gentoo, 2.43-r2::gentoo
sys-devel/binutils-config: 5.5.2::gentoo
sys-devel/gcc:             13.3.1_p20240614::gentoo
sys-devel/gcc-config:      2.11::gentoo
sys-kernel/linux-headers:  6.6-r1::gentoo (virtual/os-headers)
sys-libs/glibc:            2.39-r6::gentoo
Repositories:

gentoo
    location: /usr/portage
    sync-type: rsync
    sync-uri: rsync://rsync.gentoo.org/gentoo-portage
    priority: -1000
    volatile: True
    sync-rsync-verify-jobs: 1
    sync-rsync-verify-metamanifest: yes
    sync-rsync-extra-opts: 
    sync-rsync-verify-max-age: 3

crossdev
    location: /usr/local/portage-crossdev
    masters: gentoo
    priority: 10
    volatile: True

ACCEPT_KEYWORDS="arm64"
ACCEPT_LICENSE="@FREE"
CBUILD="aarch64_be-unknown-linux-gnu"
CFLAGS="-O2 -pipe -fomit-frame-pointer"
CHOST="aarch64_be-unknown-linux-gnu"
CONFIG_PROTECT="/etc /usr/share/gnupg/qualified.txt"
CONFIG_PROTECT_MASK="/etc/ca-certificates.conf /etc/env.d /etc/gconf /etc/gentoo-release /etc/revdep-rebuild /etc/sandbox.d /etc/terminfo"
CXXFLAGS="-O2 -pipe -fomit-frame-pointer"
DISTDIR="/tmp/distfiles"
EMERGE_DEFAULT_OPTS="--autounmask"
ENV_UNSET="CARGO_HOME DBUS_SESSION_BUS_ADDRESS DISPLAY GDK_PIXBUF_MODULE_FILE GOBIN GOPATH PERL5LIB PERL5OPT PERLPREFIX PERL_CORE PERL_MB_OPT PERL_MM_OPT XAUTHORITY XDG_CACHE_HOME XDG_CONFIG_HOME XDG_DATA_HOME XDG_RUNTIME_DIR XDG_STATE_HOME"
FCFLAGS="-O2"
FEATURES="assume-digests binpkg-docompress binpkg-dostrip binpkg-logs buildpkg-live config-protect-if-modified distlocks ebuild-locks fixlafiles ipc-sandbox merge-sync merge-wait multilib-strict network-sandbox news parallel-fetch pid-sandbox pkgdir-index-trusted preserve-libs protect-owned qa-unresolved-soname-deps sandbox sfperms strict unknown-features-warn unmerge-logs unmerge-orphans userfetch userpriv usersandbox usersync xattr"
FFLAGS="-O2"
GENTOO_MIRRORS="http://distfiles.gentoo.org"
LANG="sv_SE.utf8"
LDFLAGS="-Wl,-O1 -Wl,--as-needed"
LEX="flex"
PKGDIR="/usr/portage/packages"
PORTAGE_CONFIGROOT="/"
PORTAGE_RSYNC_OPTS="--recursive --links --safe-links --perms --times --omit-dir-times --compress --force --whole-file --delete --stats --human-readable --timeout=180 --exclude=/distfiles --exclude=/local --exclude=/packages --exclude=/.git"
PORTAGE_TMPDIR="/var/tmp"
SHELL="/bin/bash"
USE="acl arm64 big-endian bzip2 crypt gdbm iconv ipv6 libtirpc ncurses nls openmp pam pcre readline seccomp split-usr ssl test-rust unicode xattr zlib" ADA_TARGET="gcc_13" APACHE2_MODULES="authn_core authz_core socache_shmcb unixd actions alias auth_basic authn_anon authn_dbm authn_file authz_dbm authz_groupfile authz_host authz_owner authz_user autoindex cache cgi cgid dav dav_fs dav_lock deflate dir env expires ext_filter file_cache filter headers include info log_config logio mime mime_magic negotiation rewrite setenvif speling status unique_id userdir usertrack vhost_alias" CALLIGRA_FEATURES="karbon sheets words" COLLECTD_PLUGINS="df interface irq load memory rrdtool swap syslog" CPU_FLAGS_ARM="edsp v8 vfp vfp-d32 vfpv3 vfpv4" ELIBC="glibc" GPSD_PROTOCOLS="ashtech aivdm earthmate evermore fv18 garmin garmintxt gpsclock greis isync itrax navcom oceanserver oncore rtcm104v2 rtcm104v3 sirf skytraq superstar2 tsip tripmate tnt ublox" GUILE_SINGLE_TARGET="3-0" GUILE_TARGETS="3-0" INPUT_DEVICES="libinput" KERNEL="linux" LCD_DEVICES="bayrad cfontz glk hd44780 lb216 lcdm001 mtxorb text" LUA_SINGLE_TARGET="lua5-1" LUA_TARGETS="lua5-1" OFFICE_IMPLEMENTATION="libreoffice" PHP_TARGETS="php8-2" POSTGRES_TARGETS="postgres16" PYTHON_SINGLE_TARGET="python3_12" PYTHON_TARGETS="python3_12" RUBY_TARGETS="ruby32" VIDEO_CARDS="fbdev dummy" XTABLES_ADDONS="quota2 psd pknock lscan length2 ipv4options ipp2p iface geoip fuzzy condition tarpit sysrq proto logmark ipmark dhcpmac delude chaos account"
Unset:  ADDR2LINE, AR, ARFLAGS, AS, ASFLAGS, CC, CCLD, CONFIG_SHELL, CPP, CPPFLAGS, CTARGET, CXX, CXXFILT, ELFEDIT, EXTRA_ECONF, F77FLAGS, FC, GCOV, GPROF, INSTALL_MASK, LC_ALL, LD, LFLAGS, LIBTOOL, LINGUAS, MAKE, MAKEFLAGS, MAKEOPTS, NM, OBJCOPY, OBJDUMP, PORTAGE_BINHOST, PORTAGE_BUNZIP2_COMMAND, PORTAGE_COMPRESS, PORTAGE_COMPRESS_FLAGS, PORTAGE_RSYNC_EXTRA_OPTS, PYTHONPATH, RANLIB, READELF, RUSTFLAGS, SIZE, STRINGS, STRIP, YACC, YFLAGS
Comment 1 Marcus Comstedt 2025-01-11 16:41:34 UTC
Created attachment 916332 [details, diff]
Patch to fix the data corruption

Here is a patch to fix the problem.  I have also sent it upstreams.

Turns out there was a comment in the source code saying what needed to be changed for things to work on aarch64_be, it just was never implemented...  :-)
Comment 2 Larry the Git Cow gentoo-dev 2025-01-24 12:24:38 UTC
The bug has been closed via the following commit(s):

https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=a40194ff3b762e1cd6fb7dc4369896545c79bd6b

commit a40194ff3b762e1cd6fb7dc4369896545c79bd6b
Author:     Sam James <sam@gentoo.org>
AuthorDate: 2025-01-24 12:13:22 +0000
Commit:     Sam James <sam@gentoo.org>
CommitDate: 2025-01-24 12:24:15 +0000

    app-arch/xz-utils: add 5.6.4
    
    Closes: https://bugs.gentoo.org/947903
    Signed-off-by: Sam James <sam@gentoo.org>

 app-arch/xz-utils/Manifest              |   2 +
 app-arch/xz-utils/xz-utils-5.6.4.ebuild | 203 ++++++++++++++++++++++++++++++++
 2 files changed, 205 insertions(+)