Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!

Bug 890853

Summary: app-arch/xz-utils-5.4.1 illegal instruction on execution
Product: Gentoo Linux Reporter: fcrvincent <fcrvincent>
Component: Current packagesAssignee: Gentoo's Team for Core System packages <base-system>
Status: RESOLVED INVALID    
Severity: critical CC: sam, torokhov-s-a
Priority: Normal    
Version: unspecified   
Hardware: AMD64   
OS: Linux   
Whiteboard:
Package list:
Runtime testing required: ---

Description fcrvincent 2023-01-14 23:24:31 UTC
xz -d or -t of a gz file crashes with "illegal instruction"

After that every emerge of xz compressed packages fails at the early unpack phase. 

Version 5.2.10 works fine. 

CFLAGS="-march=westmere -mtune=westmere -O2  -pipe"
CPU_FLAGS_X86="mmx mmxext popcnt sse sse2 sse3 sse4_1 sse4_2 ssse3"
Comment 1 fcrvincent 2023-01-14 23:27:56 UTC
Sorry I meant xz -d or -t of a xz (not gz) file crashes with "illegal instruction"
Comment 2 Sam James archtester Gentoo Infrastructure gentoo-dev Security 2023-01-14 23:30:28 UTC
Thanks.

Could you:
1. install gdb;
2. build xz with debugging symbols (https://wiki.gentoo.org/wiki/Debugging#Per-package);
3. run: gdb --args xz -t /path/to/some/gzip/file
4. type 'r' when gdb opens, then 'bt' when it crashes.
5. share the output in full
6. run: display/i $pc (and share the output of this too)
Comment 3 Sam James archtester Gentoo Infrastructure gentoo-dev Security 2023-01-14 23:32:52 UTC
Also, emerge --info please + exact CPU model?
Comment 4 fcrvincent 2023-01-15 00:07:21 UTC
xz -t /usr/portage/distfiles/gzip-1.12.tar.xz
returns: Illegal instruction (core dumped)

gdb --args xz -t /usr/portage/distfiles/gzip-1.12.tar.xz
returns:
(gdb) r
Starting program: /usr/bin/xz -t /usr/portage/distfiles/gzip-1.12.tar.xz
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib64/libthread_db.so.1".

Program received signal SIGILL, Illegal instruction.
crc64_clmul (crc=<optimized out>, size=<optimized out>, buf=<optimized out>) at /var/tmp/portage/app-arch/xz-utils-5.4.1/work/xz-5.4.1/src/liblzma/check/crc64_fast.c:356
356	/var/tmp/portage/app-arch/xz-utils-5.4.1/work/xz-5.4.1/src/liblzma/check/crc64_fast.c: No such file or directory.
(gdb) bt
#0  crc64_clmul (crc=<optimized out>, size=<optimized out>, 
    buf=<optimized out>)
    at /var/tmp/portage/app-arch/xz-utils-5.4.1/work/xz-5.4.1/src/liblzma/check/crc64_fast.c:356
#1  lzma_crc64 (buf=<optimized out>, size=<optimized out>, crc=<optimized out>)
    at /var/tmp/portage/app-arch/xz-utils-5.4.1/work/xz-5.4.1/src/liblzma/check/crc64_fast.c:525
#2  0x00007ffff7f9291a in lzma_check_update (check=check@entry=0x55555556edc8, 
    type=<optimized out>, buf=buf@entry=0x555555568680 <out_buf> "gzip-1.12/", 
    size=<optimized out>)
    at /var/tmp/portage/app-arch/xz-utils-5.4.1/work/xz-5.4.1/src/liblzma/check/check.c:129
#3  0x00007ffff7f8d20e in block_decode (coder_ptr=0x55555556ed40, 
    allocator=<optimized out>, in=0x55555556a699 <in_buf+25> "j\"\357\376]", 
    in_pos=0x7fffffffe1f8, in_size=8167, 
    out=0x555555568680 <out_buf> "gzip-1.12/", out_pos=0x7fffffffe200, 
    out_size=8192, action=LZMA_RUN)
    at /var/tmp/portage/app-arch/xz-utils-5.4.1/work/xz-5.4.1/src/liblzma/common/block_decoder.c:127
#4  0x00007ffff7f90c12 in stream_decode_mt (coder_ptr=<optimized out>, 
    allocator=0x0, in=0x55555556a699 <in_buf+25> "j\"\357\376]", 
    in_pos=0x7fffffffe1f8, in_size=8167, 
    out=0x555555568680 <out_buf> "gzip-1.12/", out_pos=0x7fffffffe200, 
--Type <RET> for more, q to quit, c to continue without paging-- 
    out_size=8192, action=LZMA_RUN)
    at /var/tmp/portage/app-arch/xz-utils-5.4.1/work/xz-5.4.1/src/liblzma/common/stream_decoder_mt.c:1622
#5  0x00007ffff7f83c6b in lzma_code (strm=strm@entry=0x55555556c6e0 <strm>, 
    action=action@entry=LZMA_RUN)
    at /var/tmp/portage/app-arch/xz-utils-5.4.1/work/xz-5.4.1/src/liblzma/common/common.c:286
#6  0x00005555555594a8 in coder_normal (pair=0x55555556c780 <pair>)
    at /var/tmp/portage/app-arch/xz-utils-5.4.1/work/xz-5.4.1/src/xz/coder.c:872
#7  coder_run (filename=<optimized out>)
    at /var/tmp/portage/app-arch/xz-utils-5.4.1/work/xz-5.4.1/src/xz/coder.c:1086
#8  0x0000555555557802 in main (argc=<optimized out>, argv=<optimized out>)
    at /var/tmp/portage/app-arch/xz-utils-5.4.1/work/xz-5.4.1/src/xz/main.c:282
(gdb)
Comment 5 fcrvincent 2023-01-15 00:12:27 UTC
And:
(gdb) display/i $pc
1: x/i $pc
=> 0x7ffff7f92b78 <lzma_crc64+200>:	pclmulhqhqdq %xmm4,%xmm2
Comment 6 Sam James archtester Gentoo Infrastructure gentoo-dev Security 2023-01-15 00:14:11 UTC
Thanks. emerge --info and which CPU exactly?
Comment 7 fcrvincent 2023-01-15 00:22:17 UTC
emerge --info
Portage 3.0.43 (python 3.10.9-final-0, default/linux/amd64/17.1/desktop/gnome/systemd, gcc-11, glibc-2.36-r5, 5.15.80-gentoo-x86_64 x86_64)
=================================================================
System uname: Linux-5.15.80-gentoo-x86_64-x86_64-Intel-R-_Core-TM-_i3_CPU_M_370_@_2.40GHz-with-glibc2.36
KiB Mem:     7934256 total,   1386892 free
KiB Swap:    6291452 total,   6290932 free
Timestamp of repository gentoo: Sat, 14 Jan 2023 18:00:01 +0000
Head commit of repository gentoo: c1ad1ae9e8b4f2b2b1a85c57400fdae980aed314
Timestamp of repository haskell: Sat, 14 Jan 2023 11:32:38 +0000
Head commit of repository haskell: 2dff20a64145294924c86967148c65f55647651f

sh bash 5.1_p16-r2
ld GNU ld (Gentoo 2.39 p5) 2.39.0
ccache version 4.7.4 [enabled]
app-misc/pax-utils:        1.3.5::gentoo
app-shells/bash:           5.1_p16-r2::gentoo
dev-java/java-config:      2.3.1::gentoo
dev-lang/perl:             5.36.0-r1::gentoo
dev-lang/python:           2.7.18_p16::gentoo, 3.10.9::gentoo, 3.11.1::gentoo
dev-lang/rust-bin:         1.66.1::gentoo
dev-util/ccache:           4.7.4::gentoo
dev-util/cmake:            3.24.3::gentoo
dev-util/meson:            0.64.1::gentoo
sys-apps/baselayout:       2.9::gentoo
sys-apps/sandbox:          2.29::gentoo
sys-apps/systemd:          252.4::gentoo
sys-devel/autoconf:        2.71-r5::gentoo
sys-devel/automake:        1.16.5::gentoo
sys-devel/binutils:        2.39-r4::gentoo
sys-devel/binutils-config: 5.4.1::gentoo
sys-devel/gcc:             11.3.1_p20221209::gentoo
sys-devel/gcc-config:      2.8::gentoo
sys-devel/libtool:         2.4.7::gentoo
sys-devel/llvm:            15.0.6-r1::gentoo
sys-devel/make:            4.3::gentoo
sys-kernel/linux-headers:  5.15-r3::gentoo (virtual/os-headers)
sys-libs/glibc:            2.36-r5::gentoo
Repositories:

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

haskell
    location: /var/db/repos/haskell
    sync-type: git
    sync-uri: https://github.com/gentoo-mirror/haskell.git
    masters: gentoo
    volatile: True

ACCEPT_KEYWORDS="amd64"
ACCEPT_LICENSE="* -@EULA"
CBUILD="x86_64-pc-linux-gnu"
CFLAGS="-march=westmere -mtune=westmere -O2  -pipe"
CHOST="x86_64-pc-linux-gnu"
CONFIG_PROTECT="/etc /usr/share/gnupg/qualified.txt"
CONFIG_PROTECT_MASK="/etc/ca-certificates.conf /etc/dconf /etc/env.d /etc/fonts/fonts.conf /etc/gconf /etc/gentoo-release /etc/revdep-rebuild /etc/sandbox.d /etc/terminfo /etc/texmf/language.dat.d /etc/texmf/language.def.d /etc/texmf/updmap.d /etc/texmf/web2c"
CXXFLAGS="-march=westmere -mtune=westmere -O2  -pipe"
DISTDIR="/usr/portage/distfiles"
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 -pipe"
FEATURES="assume-digests binpkg-docompress binpkg-dostrip binpkg-logs buildpkg-live ccache config-protect-if-modified distlocks ebuild-locks fixlafiles ipc-sandbox merge-sync multilib-strict network-sandbox news parallel-fetch pid-sandbox 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 -pipe"
GENTOO_MIRRORS="http://distfiles.gentoo.org"
LANG="en_GB.utf8"
LDFLAGS="-Wl,-O1 -Wl,--as-needed"
LEX="flex"
LINGUAS="en_GB fr_FR"
MAKEOPTS="-j4"
PKGDIR="/var/cache/binpkgs"
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="X a52 aac acl acpi alsa amd64 branding bzip2 cairo cdda cdr cli colord crypt cups dbus dri dts dvd dvdr eds encode evo exif flac fortran gdbm gif gnome-keyring gnome-online-accounts gpm gstreamer gtk gui iconv icu introspection ipv6 jpeg lcms libglvnd libnotify libsecret libtirpc lvm mad mng mp3 mp4 mpeg multilib nautilus ncurses networkmanager nls nptl ogg opengl openmp pam pango pcre pdf png policykit ppds pulseaudio readline sdl seccomp sound spell split-usr ssl startup-notification svg sysprof systemd test-rust tiff tracker truetype udev udisks unicode upower usb vaapi vorbis wayland wxwidgets x264 xattr xcb xft xml xv xvid zlib" ABI_X86="64" ADA_TARGET="gnat_2021" APACHE2_MODULES="authn_core authz_core socache_shmcb unixd actions alias auth_basic authn_alias authn_anon authn_dbm authn_default authn_file authz_dbm authz_default authz_groupfile authz_host authz_owner authz_user autoindex cache cgi cgid dav dav_fs dav_lock deflate dir disk_cache env expires ext_filter file_cache filter headers include info log_config logio mem_cache 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_X86="mmx mmxext popcnt sse sse2 sse3 sse4_1 sse4_2 ssse3" ELIBC="glibc" GPSD_PROTOCOLS="ashtech aivdm earthmate evermore fv18 garmin garmintxt gpsclock greis isync itrax mtk3301 nmea ntrip navcom oceanserver oldstyle oncore rtcm104v2 rtcm104v3 sirf skytraq superstar2 timing tsip tripmate tnt ublox ubx" INPUT_DEVICES="evdev keyboard mouse synaptics virtualbox" KERNEL="linux" L10N="en-GB fr-FR fr zh-CN" LCD_DEVICES="bayrad cfontz cfontz633 glk hd44780 lb216 lcdm001 mtxorb ncurses text" LIBREOFFICE_EXTENSIONS="presenter-console presenter-minimizer" LUA_SINGLE_TARGET="lua5-1" LUA_TARGETS="lua5-1" OFFICE_IMPLEMENTATION="libreoffice" PHP_TARGETS="php7-4 php8-0" POSTGRES_TARGETS="postgres12 postgres13" PYTHON_SINGLE_TARGET="python3_10" PYTHON_TARGETS="python3_10" RUBY_TARGETS="ruby27" SANE_BACKENDS="net" USERLAND="GNU" VIDEO_CARDS="intel i965" XTABLES_ADDONS="quota2 psd pknock lscan length2 ipv4options ipset ipp2p iface geoip fuzzy condition tee tarpit sysrq proto steal rawnat logmark ipmark dhcpmac delude chaos account"
Unset:  ADDR2LINE, AR, ARFLAGS, AS, ASFLAGS, CC, CCLD, CONFIG_SHELL, CPP, CPPFLAGS, CTARGET, CXX, CXXFILT, ELFEDIT, EMERGE_DEFAULT_OPTS, EXTRA_ECONF, F77FLAGS, FC, GCOV, GPROF, INSTALL_MASK, LC_ALL, LD, LFLAGS, LIBTOOL, MAKE, MAKEFLAGS, NM, OBJCOPY, OBJDUMP, PORTAGE_BINHOST, PORTAGE_BUNZIP2_COMMAND, PORTAGE_COMPRESS, PORTAGE_COMPRESS_FLAGS, PORTAGE_RSYNC_EXTRA_OPTS, RANLIB, READELF, RUSTFLAGS, SIZE, STRINGS, STRIP, YACC, YFLAGS
Comment 8 fcrvincent 2023-01-15 00:22:44 UTC
And:

cat /proc/cpuinfo 
processor	: 0
vendor_id	: GenuineIntel
cpu family	: 6
model		: 37
model name	: Intel(R) Core(TM) i3 CPU       M 370  @ 2.40GHz
stepping	: 5
microcode	: 0x2
cpu MHz		: 2393.915
cache size	: 3072 KB
physical id	: 0
siblings	: 4
core id		: 0
cpu cores	: 2
apicid		: 0
initial apicid	: 0
fpu		: yes
fpu_exception	: yes
cpuid level	: 11
wp		: yes
flags		: fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush dts acpi mmx fxsr sse sse2 ht tm pbe syscall nx rdtscp lm constant_tsc arch_perfmon pebs bts rep_good nopl xtopology nonstop_tsc cpuid aperfmperf pni dtes64 monitor ds_cpl vmx est tm2 ssse3 cx16 xtpr pdcm pcid sse4_1 sse4_2 popcnt lahf_lm pti tpr_shadow vnmi flexpriority ept vpid dtherm arat
vmx flags	: vnmi preemption_timer invvpid ept_x_only flexpriority tsc_offset vtpr mtf vapic ept vpid unrestricted_guest
bugs		: cpu_meltdown spectre_v1 spectre_v2 spec_store_bypass l1tf mds swapgs itlb_multihit mmio_unknown
bogomips	: 4787.83
clflush size	: 64
cache_alignment	: 64
address sizes	: 36 bits physical, 48 bits virtual
power management:

processor	: 1
vendor_id	: GenuineIntel
cpu family	: 6
model		: 37
model name	: Intel(R) Core(TM) i3 CPU       M 370  @ 2.40GHz
stepping	: 5
microcode	: 0x2
cpu MHz		: 2378.730
cache size	: 3072 KB
physical id	: 0
siblings	: 4
core id		: 2
cpu cores	: 2
apicid		: 4
initial apicid	: 4
fpu		: yes
fpu_exception	: yes
cpuid level	: 11
wp		: yes
flags		: fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush dts acpi mmx fxsr sse sse2 ht tm pbe syscall nx rdtscp lm constant_tsc arch_perfmon pebs bts rep_good nopl xtopology nonstop_tsc cpuid aperfmperf pni dtes64 monitor ds_cpl vmx est tm2 ssse3 cx16 xtpr pdcm pcid sse4_1 sse4_2 popcnt lahf_lm pti tpr_shadow vnmi flexpriority ept vpid dtherm arat
vmx flags	: vnmi preemption_timer invvpid ept_x_only flexpriority tsc_offset vtpr mtf vapic ept vpid unrestricted_guest
bugs		: cpu_meltdown spectre_v1 spectre_v2 spec_store_bypass l1tf mds swapgs itlb_multihit mmio_unknown
bogomips	: 4787.83
clflush size	: 64
cache_alignment	: 64
address sizes	: 36 bits physical, 48 bits virtual
power management:

processor	: 2
vendor_id	: GenuineIntel
cpu family	: 6
model		: 37
model name	: Intel(R) Core(TM) i3 CPU       M 370  @ 2.40GHz
stepping	: 5
microcode	: 0x2
cpu MHz		: 2393.915
cache size	: 3072 KB
physical id	: 0
siblings	: 4
core id		: 0
cpu cores	: 2
apicid		: 1
initial apicid	: 1
fpu		: yes
fpu_exception	: yes
cpuid level	: 11
wp		: yes
flags		: fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush dts acpi mmx fxsr sse sse2 ht tm pbe syscall nx rdtscp lm constant_tsc arch_perfmon pebs bts rep_good nopl xtopology nonstop_tsc cpuid aperfmperf pni dtes64 monitor ds_cpl vmx est tm2 ssse3 cx16 xtpr pdcm pcid sse4_1 sse4_2 popcnt lahf_lm pti tpr_shadow vnmi flexpriority ept vpid dtherm arat
vmx flags	: vnmi preemption_timer invvpid ept_x_only flexpriority tsc_offset vtpr mtf vapic ept vpid unrestricted_guest
bugs		: cpu_meltdown spectre_v1 spectre_v2 spec_store_bypass l1tf mds swapgs itlb_multihit mmio_unknown
bogomips	: 4787.83
clflush size	: 64
cache_alignment	: 64
address sizes	: 36 bits physical, 48 bits virtual
power management:

processor	: 3
vendor_id	: GenuineIntel
cpu family	: 6
model		: 37
model name	: Intel(R) Core(TM) i3 CPU       M 370  @ 2.40GHz
stepping	: 5
microcode	: 0x2
cpu MHz		: 1877.800
cache size	: 3072 KB
physical id	: 0
siblings	: 4
core id		: 2
cpu cores	: 2
apicid		: 5
initial apicid	: 5
fpu		: yes
fpu_exception	: yes
cpuid level	: 11
wp		: yes
flags		: fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush dts acpi mmx fxsr sse sse2 ht tm pbe syscall nx rdtscp lm constant_tsc arch_perfmon pebs bts rep_good nopl xtopology nonstop_tsc cpuid aperfmperf pni dtes64 monitor ds_cpl vmx est tm2 ssse3 cx16 xtpr pdcm pcid sse4_1 sse4_2 popcnt lahf_lm pti tpr_shadow vnmi flexpriority ept vpid dtherm arat
vmx flags	: vnmi preemption_timer invvpid ept_x_only flexpriority tsc_offset vtpr mtf vapic ept vpid unrestricted_guest
bugs		: cpu_meltdown spectre_v1 spectre_v2 spec_store_bypass l1tf mds swapgs itlb_multihit mmio_unknown
bogomips	: 4787.83
clflush size	: 64
cache_alignment	: 64
address sizes	: 36 bits physical, 48 bits virtual
power management:
Comment 9 fcrvincent 2023-01-15 00:32:11 UTC
UPDATE:

I removed -march=westmere -mtune=westmere from my CFLAGS
and xz now works!!!

app-arch/xz-utils Installed versions:  5.4.1

and xz -t /usr/portage/distfiles/gzip-1.12.tar.xz no longer crashes
Comment 10 Sam James archtester Gentoo Infrastructure gentoo-dev Security 2023-01-15 00:40:08 UTC
(In reply to fcrvincent from comment #9)
> UPDATE:
> 
> I removed -march=westmere -mtune=westmere from my CFLAGS
> and xz now works!!!
> 
> app-arch/xz-utils Installed versions:  5.4.1
> 
> and xz -t /usr/portage/distfiles/gzip-1.12.tar.xz no longer crashes

Thanks for the update! That's so frustrating, the wikipedia article for westmere lists the instruction, and Arrandale (your CPU) says it's westmere -- but indeed it's not there!
Comment 11 fcrvincent 2023-01-15 00:57:15 UTC
Thanks for your help.

Yes I tried to be too clever with my CFLAGS a few weeks ago and put the Westmere arch that was documented on the net for my CPU.

That was a bad idea!
Comment 12 Sergey Torokhov 2023-01-15 06:44:19 UTC
I have the similar issue for xz-utuls-5.4.1 on PC with wesmere flags for intel i3 550: after update to it xz archives don't unpack.
Comment 13 Sergey Torokhov 2023-01-15 07:24:09 UTC
Yes the problem was in automatic applying "-mpclmul" flag if "-march=westmere" is used. I my case for Intel Core i3 550 I have setup CFLAGS="-march=westmere -mno-aes -mno-avx -O2 -pipe" etc.

The output of "cpuid2cpuflags" util is: 
> CPU_FLAGS_X86: mmx mmxext popcnt sse sse2 sse3 sse4_1 sse4_2 ssse3

Moreover the https://wiki.gentoo.org/wiki/Safe_CFLAGS article advises (in Note):
> You might need to add -mno-aes -mno-pclmul, especially for i3 (enabled by default).
and the "grep -m1 -e aes -e pclmulqdq /proc/cpuinfo" outputs nothing.

I rebuild the app-arch/xz-utils-5.4.1 with individual env setup with "-mno-pclmul":
> CFLAGS="${CFLAGS} -march=westmere -mno-aes -mno-avx -mno-pclmul -O2 -pipe"
> CXXFLAGS="${CFLAGS}"
and it fixes the problem.

So the common solution is to add "-mno-pclmul" globaly for intel core i3 cpu's as adivised in Gentoo wiki article.
Comment 14 fcrvincent 2023-01-15 11:28:57 UTC
Good point, thanks.

A global CFLAGS="-march=westmere -mno-pclmul -mtune=westmere -O2  -pipe"

Now allows xz to work fine on my i3 processor. 

And will certainly avert any problem from applications that may use the pclmul instructions.
Comment 15 Sergey Torokhov 2023-01-15 15:26:43 UTC
"-mno-aes" is also recomended to add for westmere i3 processors in "Safe CFLAGS" gentoo wiki article.
Comment 16 fcrvincent 2023-01-15 16:01:24 UTC
thanks, I added the -mno-aes option too.