SIGILL in Docker: How a JDK AOT Cache Crashed Axelix
The cause of a SIGILL error that made the JVM shut down before reaching the first log line for some Axelix Master users, the machine code in the JDK AOT cache, and how it was fixed.
Imagine running a Java application from a Docker image. The container starts, but the JVM shuts down before the first log line appears, and the crash report says "SIGILL". This is exactly what happened to some Axelix Master users. In this post we explain the cause of the error, how the AOT cache that ships with JDK 25 works, and which design detail led to the problem. It is a useful case for anyone who distributes precompiled images.
How the error appeared
The bug report was opened in the Axelix repository as issue 1744. All of the incoming dump files showed the same stack frame: ~AdapterBlob. The only thing that differed was the type of the instruction that could not be executed. On ARM64 machines, the JVM crashed on an instruction from the SVE (Scalable Vector Extension) family. However, the CPU feature list in the reports did not include SVE. On the x86-64 side, we reproduced the same error with a virtual CPU that lacked AVX support. Here the crash happened on the vzeroupper instruction from the AVX family.
On two different architectures, in the same place, the crash came from vector instructions that the CPU did not have. As a temporary fix, we removed the AOT cache from the Master image and released version 1.2.0 that way. Then we started looking for the real cause.
What is the AOT cache?
At every JVM startup, the same work is repeated: classes are read from JAR files, bytecode is parsed and verified, classes are linked, and static initializers run. After that, code runs in the interpreter for a while, the profile is collected, and only then can the JIT compiler produce well-optimized machine code. In a Spring Boot application with thousands of classes, most of the startup time goes to this work.
Project Leyden aims to make this work reusable across runs. The project's first concrete output is the AOT cache. With JEP 483 in JDK 24, classes could be written to the cache in a loaded and linked state. JEP 514 in JDK 25 simplified command-line usage, and JEP 515 added method profiles to the cache, allowing the JIT to optimize earlier.
The process goes through three stages:
- Training: The application is run with a representative workload, and the JVM records which classes it loads and links and how the methods behave.
- Preparation: A separate JVM reads this record and produces the cache file.
- Production: Subsequent runs start with the
-XX:AOTCacheparameter and use the ready data instead of doing the work again.
The Dockerfile of Axelix Master sets up this flow with a multi-stage build. A simplified version looks like this:
FROM eclipse-temurin:25-jre-alpine AS training
WORKDIR /application
COPY build/libs/master.jar master.jar
RUN java -XX:AOTMode=record -XX:AOTConfiguration=app.aotconf \
-Dspring.context.exit=onRefresh -jar master.jar
RUN java -XX:AOTMode=create -XX:AOTConfiguration=app.aotconf \
-XX:AOTCache=app.aot -jar master.jar
FROM eclipse-temurin:25-jre-alpine AS final
WORKDIR /application
COPY --from=training /application/master.jar /application/app.aot ./
ENTRYPOINT exec java -XX:AOTCache=app.aot -cp master.jar \
org.springframework.boot.loader.launch.JarLauncher
The data in the cache can be divided into three types: class metadata, method profiles, and heap objects. All of these are CPU-independent data structures. The fourth type, the AOT code cache, contains actual machine code, and that is where the source of the problem lies.
AOTAdapterCaching and the hidden dependency
HotSpot generates small glue code called "adapters" so that interpreted and compiled code can call each other. The interpreter passes arguments on its own stack, while compiled code expects them in registers according to the platform's ABI. That is why adapters are needed in both directions: from interpreted to compiled, and the reverse.
In JDK 25, the AOTAdapterCaching option is enabled by default. This means adapters are generated during the training phase and written to the cache as machine code. Here lies a hidden dependency: every piece of code HotSpot generates takes its shape according to the CPU it is running on at the moment of generation. An adapter generated on a machine that supports AVX-512 may use those registers, and an adapter generated on a machine that supports SVE may contain SVE instructions. On the machine where it was prepared, there is no problem. But on a machine without these features, the first call runs into an instruction the CPU does not know, and the kernel sends SIGILL.
Why the JVM did not protect us
Before accepting a cache, the JVM performs some checks. It compares the JDK version, operating system, architecture (x64 or aarch64), classpath, and settings such as the GC and compressed oops. If there is a mismatch, in the default -XX:AOTMode=auto mode it prints a warning and continues without the cache. Startup gets slower, but the application still runs.
The problem was this: JDK 25 did not check CPU features within the same architecture. The "x64" label covers both a modern server processor that supports AVX-512 and an older laptop processor that does not know those instructions. The cache was accepted, and the adapters inside it were used as they were.
Looking at how our image is produced makes the picture clear. The release job runs on a GitHub-hosted runner and builds a multi-platform image. The amd64 variant is trained on whatever CPU the runner happens to have at that moment. These runners are cloud virtual machines, and some of them support AVX-512. The arm64 variant, because the runner is x86, is trained under emulation with QEMU. QEMU's default max CPU model includes SVE as well. However, most ARM64 machines that our users run (such as Apple Silicon, Graviton2, and Ampere Altra) largely lack SVE. In other words, our build machines had more features than our users' machines. It was no coincidence that the crash matched this pattern exactly.
Upstream bug
During our investigation, we found the adoptium-support#1507 issue, which describes the same problem. It reported that a cache produced on a Zen 5 processor with AVX-512 crashed inside ~AdapterBlob on a Zen 2 processor without AVX-512. The root cause was again that GitHub Actions runners sometimes have AVX-512 and sometimes don't.
The topic was later moved to OpenJDK as JDK-8388703. The HotSpot developers' response was pragmatic. In JDK 25, only adapters remained as AOT code (the stub cache was already disabled), and their contribution to performance was small. So instead of backporting the CPU checks, they chose to disable adapter caching by default in JDK 25. This change is included in JDK 25.0.5 and comes with the following comment in the code:
// Disable adapters caching which requires CPU features matching checks
// (implemented by JDK-8377507 and JDK-8381975) which we don't
// have in this version of code.
FLAG_SET_ERGO_IF_DEFAULT(AOTAdapterCaching, false);
The real fix arrives in JDK 27. First, the CPU features of the build machine are written into the AOT code cache. Second, at startup the recorded features must exactly match the current CPU. If they don't match, the JVM prints a warning and skips only the machine code, continuing to use the rest of the cache. The worst case is a slightly slower startup, not a crash.
Our fix
The fix came with change #1767. We turned the AOT cache back on, but we generate it without adapters:
RUN java \
-XX:+UnlockDiagnosticVMOptions \
-XX:-AOTAdapterCaching \
-XX:AOTMode=create \
-XX:AOTConfiguration=app.aotconf \
-XX:AOTCache=app.aot \
-jar /application/master.jar
Since this flag is a diagnostic option, -XX:+UnlockDiagnosticVMOptions is required first. With this setting, no machine code remains in the cache, and the JVM verifies this at startup. What remains is class metadata, profiles, and heap objects. These are valid on every CPU of the same architecture. Adapters are generated at runtime on the user's machine, according to the user's CPU anyway. In a local measurement, out of 15,201 classes loaded during startup in an image produced with the corrected Dockerfile, 10,933 — roughly 72 percent — came from the cache. Context readiness time dropped from about 7.3 seconds to 5.4 seconds on a developer laptop.
We discussed other options in the PR. The first was to wait for JDK 25.0.5 and keep adapter caching enabled. But 25.0.5 doesn't make adapters safe, it only disables them. The result is the same as our flag. The second was to switch directly to JDK 27. Since most users run Axelix on Docker or Kubernetes, this would have been acceptable for us. However, Spring Boot 4.1 officially supports Java up to 26, and Java 27 support is expected with Spring Boot 4.2. So we combined the explicit flag. It works with today's JDK 25 builds, and since the default value in 25.0.5 is the same, it remains consistent.
The JDK 27 side
When Spring Boot 4.2 is released, we plan to move Axelix to JDK 27. There, re-enabling AOTAdapterCaching will be safe, because on a mismatch the JVM discards the code and continues. But being safe doesn't mean being useful. Since JDK 27 requires an exact match, it is quite unlikely that an image produced on a GitHub runner or under QEMU will exactly match the user's CPU. In most cases the adapters will still be discarded. For the distributed images to truly benefit from AOT code, the code needs to be generated for a portable CPU baseline. An enhancement proposal for this, JDK-8377630, is still open. Until it lands, it is more accurate to view the AOT cache in distributed images mostly as a data cache.
Takeaways
- The JDK AOT cache provides a real and easy startup gain for Spring Boot applications in Docker. A training-stage multi-stage Dockerfile is usually enough.
- Before JDK 25.0.5, if you produce the cache on one machine and run it on another, create it with
-XX:+UnlockDiagnosticVMOptions -XX:-AOTAdapterCaching. Otherwise, the users' CPUs must have every feature your build machine has. - With multi-architecture images, each platform runs its own training and preparation stages, so a separate cache per architecture is created automatically.
- The JVM validates the cache and safely falls back on a mismatch. Before JDK 27, the only exception is machine code written into the cache.
The fix will be released with the next Axelix version. If you're curious about the details, the full story is in issue 1744 and change 1767.
Comments (0)
No comments yet; be the first.
Leave a comment