Skip to content

linux-amd64 native library in 1.13.0/1.14.0 requires AVX2/BMI2 (x86-64-v3), SIGILL on older CPUs #186

Closed

Description

@mangewallin

Summary

Since 1.13.0, net/jpountz/util/linux/amd64/liblz4-java.so is compiled for x86-64-v3 (AVX2, BMI2, LZCNT, MOVBE). On x86-64 CPUs without those extensions the JVM aborts with SIGILL the first time the JNI implementation is used. 1.12.1 and earlier run fine on the same machine.

This looks unintentional: the release notes for 1.13.0 and 1.14.0 don't mention a new CPU baseline, and nothing in the build configuration changed between 1.12.1 and 1.13.0.

Crash

lz4-java 1.14.0, Temurin 25.0.5, linux-amd64, Intel Xeon E5-2640 (Sandy Bridge: AVX, no AVX2/BMI2). Triggered by the Kafka client's first use of lz4.

# A fatal error has been detected by the Java Runtime Environment:
#
#  SIGILL (0x4) at pc=0x00007f9e85c30d8c, pid=5330, tid=5403
#
# Problematic frame:
# C  [liblz4-java-17693407819068721459.so+0x20d8c]  XXH32+0x4c

The instruction at that offset is BMI2:

0000000000020d40 <XXH32>:
   ...
   20d8a:  addl   %ecx, %edx
   20d8c:  rorxl  $0x13, %edx, %edx     <-- SIGILL
   20d92:  imull  $0x9e3779b1, %edx, %ecx

In 1.12.1 the same place is roll $0xd, %edx.

Comparison of the published linux-amd64 libraries

Version Compiler (.comment) %ymm operands rorx
1.12.1 GCC (Ubuntu 13.3.0-6ubuntu2~24.04.1) 13.3.0 0 0
1.13.0 GCC (Ubuntu 15.2.0-16ubuntu1) 15.2.0 913 126
1.14.0 GCC (Ubuntu 15.2.0-16ubuntu1) 15.2.0 913 126

To check a jar:

unzip -p lz4-java-1.14.0.jar net/jpountz/util/linux/amd64/liblz4-java.so > liblz4-java.so
objdump -d liblz4-java.so | grep -c '%ymm'

The linux-i386 library (same GCC, -m32) and the windows-amd64 DLL in 1.14.0 contain no AVX2/BMI2 code. I did not check the darwin-x86_64 library.

Likely cause

The Linux natives are built in .github/workflows/build-all-and-publish.yml on runs-on: ubuntu-latest, and the amd64 flags (-O2 ... -mno-omit-leaf-frame-pointer -fcf-protection) contain no -march, so the baseline is whatever the runner's GCC defaults to.

GitHub is migrating ubuntu-latest to Ubuntu 26.04 between 19 Oct and 19 Nov 2026 (actions/runner-images#14748). 1.12.1 was released on 22 Oct and still built on 24.04; 1.13.0 on 4 Nov built with the new toolchain. The 26.04 image uses Ubuntu's amd64v3 package variant (actions/runner-images#14600), and other projects report that its GCC is configured with --with-arch-64=x86-64-v3 (for example Pagefind/pagefind#1425). That would also explain why the -m32 build is unaffected. I have not confirmed the GCC default from an official source.

Activity

  1. added a commit that references this issue on Nov 16, 2026
    e5ffc74
  2. yawkat commented on Nov 16, 2026

    @yawkat
    Owner

    Fixed in 1.14.1, thanks for the detailed report.

    Your diagnosis was right: since ubuntu-latest moved to Ubuntu 26.04, the toolchain defaults (and the prebuilt libgcc/CRT objects that end up in the library) targeted newer CPUs. Besides amd64 (x86-64-v3), this also affected s390x (z15) and riscv64 (RVA23).

    In 1.14.1 (#187):

    • The Linux natives are built in a pinned Debian stable container, with an explicit CPU baseline per arch: x86-64, i686, armv8-a, POWER8 (lower than the POWER9 of earlier releases), z13 and rv64gc. The Windows DLL is now plain x86-64 too; earlier releases contained SSE3.
    • CI checks every native library in the jar for instructions above its baseline, for the minimum glibc/macOS version and for its library dependencies (scripts/check_natives.py), and runs that check against the 1.13.0 jar as a regression test.

    The 1.14.1 Linux natives also pass a compress/decompress round trip under QEMU emulating a Sandy Bridge CPU.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions